]> git.decadent.org.uk Git - dak.git/blobdiff - dakweb/queries/suite.py
Keep track of when a package was last added to a suite
[dak.git] / dakweb / queries / suite.py
index e04c20842e585256a6273bf7651a9852450f6a4b..5446f699b8f622d39a0bfbf1b7343de979bbc325 100644 (file)
@@ -1,4 +1,11 @@
-#!/usr/bin/python
+""" Suite related queries
+
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@copyright: 2014  Mark Hymers <mhy@debian.org>
+@license: GNU General Public License version 2 or later
+
+@newfield maps: Mapping, Mappings
+"""
 
 import bottle
 import json
@@ -6,14 +13,25 @@ import json
 from daklib.dbconn import DBConn, Suite
 from dakweb.webregister import QueryRegister
 
+
 @bottle.route('/suites')
 def suites():
     """
-    suites()
+    Give information about all known suites.
 
-    returns: list of dictionaries
+    @maps: name maps to Suite: in the release file
+    @maps: codename maps to Codename: in the release file.
+    @maps: dakname is an internal name and should not be relied upon.
+
+    @rtype: list of dictionaries
+    @return: Dictionaries made out of
+             - name
+             - codename
+             - dakname
+             - archive
+             - architectures
+             - components
 
-    Give information about all known suites
     """
 
     s = DBConn().session()
@@ -21,12 +39,15 @@ def suites():
     q = q.order_by(Suite.suite_name)
     ret = []
     for p in q:
-        ret.append({'name':       p.suite_name,
+        ret.append({'name':       p.release_suite_output,
                     'codename':   p.codename,
+                    'dakname':    p.suite_name,
                     'archive':    p.archive.archive_name,
                     'architectures': [x.arch_string for x in p.architectures],
                     'components': [x.component_name for x in p.components]})
 
+    s.close()
+
     return json.dumps(ret)
 
 QueryRegister().register_path('/suites', suites)
@@ -34,14 +55,27 @@ QueryRegister().register_path('/suites', suites)
 @bottle.route('/suite/<suite>')
 def suite(suite=None):
     """
-    suite(suite)
-
-    returns: dictionary
-
     Gives information about a single suite.  Note that this routine will look
     up a suite first by the main suite_name, but then also by codename if no
     suite is initially found.  It can therefore be used to canonicalise suite
-    names
+    names.
+
+    @type suite: string
+    @param suite: Name or codename of the suite.
+    @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites.
+
+    @maps: name maps to Suite: in the release file
+    @maps: codename maps to Codename: in the release file.
+    @maps: dakname is an internal name and should not be relied upon.
+
+    @rtype: dictionary
+    @return: A dictionary of
+             - name
+             - codename
+             - dakname
+             - archive
+             - architectures
+             - components
     """
 
     if suite is None:
@@ -56,6 +90,7 @@ def suite(suite=None):
 
     if q.count() > 1:
         # This would mean dak is misconfigured
+        s.close()
         return bottle.HTTPError(503, 'Multiple suites found: configuration error')
     elif q.count() == 1:
         so = q[0]
@@ -64,18 +99,21 @@ def suite(suite=None):
         q = s.query(Suite).filter(Suite.codename == suite)
         if q.count() > 1:
             # This would mean dak is misconfigured
+            s.close()
             return bottle.HTTPError(503, 'Multiple suites found: configuration error')
         elif q.count() == 1:
             so = q[0]
 
     if so is not None:
-        so = {'name':       so.suite_name,
+        so = {'name':       so.release_suite_output,
               'codename':   so.codename,
+              'dakname':    so.suite_name,
               'archive':    so.archive.archive_name,
               'architectures': [x.arch_string for x in so.architectures],
               'components': [x.component_name for x in so.components]}
 
+    s.close()
+
     return json.dumps(so)
 
 QueryRegister().register_path('/suite', suite)
-