Commits

Anonymous committed 3fd5f5d

Added page with easy_installability summary.

Comments (0)

Files changed (5)

 DB_PASSWORD = 'cheesecake'
 
 # Set these to absolute paths.
-STATIC_FILES_DIRECTORY = '/static'
-TEMPLATES_DIRECTORY = '/templates'
+STATIC_FILES_DIRECTORY = 'static'
+TEMPLATES_DIRECTORY = 'templates'
             self.relative = relative
             self.subindices = subindices
 
+        def get_subindex(self, name):
+            """Get subindex that have given `name`.
+            Returns None when subindex wasn't found.
+            """
+            for subindex in self.subindices:
+                if subindex.name == name:
+                    return subindex
+
     class SubIndex(object):
         def __init__(self, name, value, details):
             self.name = name
             'CODE_KWALITEE': serialize_main_index(self.code_kwalitee),
         }
 
+    def can_be_installed(self):
+        """Return True if score has Installability/install score > 0.
+        (which means it can be installed via easy_install).
+        """
+        subindex = self.installability.get_subindex('install')
+
+        if subindex and subindex.value > 0:
+            return True
+
+        return False
+
 class CheesecakeScoreFromValues(CheesecakeScore):
     def __init__(self, installability, documentation, code_kwalitee):
         self.installability = installability

templates/easy_installability.html

+#encoding utf-8
+<html>
+  <head>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+    <title>Cheesecake service: Easy_installability</title>
+    <link rel="stylesheet" href="style.css" type="text/css" />
+  </head>
+
+  <body>
+
+    <h2>List of packages that can and cannot be installed via easy_install</h2>
+
+    <p><em>Note: includes only packages updated after August 10th, 2006.</em></p>
+
+    <table>
+      <tr>
+        <th>installable via easy_install</th>
+        <th>NOT installable via easy_install</th>
+      </tr>
+      <tr>
+        <td>
+          #for release in $easy_installable_releases
+            <a href="score/$release[0]/$release[1]">$release[0]-$release[1]</a></em><br />
+          #end for
+        </td>
+
+        <td>
+          #for release in $not_easy_installable_releases
+            <a href="score/$release[0]/$release[1]">$release[0]-$release[1]</a></em><br />
+          #end for
+        </td>
+      </tr>
+    </table>
+
+  </body>
+</html>

templates/index.html

 
     <p><a href="top10">TOP 10 list</a> for each category.</p>
     <p><a href="scores">Full scores list</a> sorted alphabetically.</p>
+    <p><a href="easy_installability">List of packages that can and cannot be installed via easy_install</a>.</p>
 
     <p class="head">Best packages</p>
 
     '/scores/documentation', 'scores_documentation',
     '/scores/code_kwalitee', 'scores_code_kwalitee',
     '/score/(.*)/(.*)', 'score',
+    '/easy_installability', 'easy_installability',
 
     '/log/(.*)', 'log',
 
 
         web.render('score.html')
 
+class easy_installability(HandlerWithStore):
+    def _GET(self):
+        easy_installable_releases = []
+        not_easy_installable_releases = []
+
+        for release, score in self.store.score.iteritems():
+            if score.can_be_installed():
+                easy_installable_releases.append(release)
+            else:
+                not_easy_installable_releases.append(release)
+
+        easy_installable_releases.sort()
+        not_easy_installable_releases.sort()
+
+        web.render('easy_installability.html')
+
 class StaticHandler(object):
     def GET(self, filename):
         if not filename: