+"""
+The Debian Archive Kit web api.
+
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@license: GNU General Public License version 2 or later
+"""
#!/usr/bin/python
-# Main script to run the dakweb server and also
-# to provide the list_paths and path_help functions
+""" Main script to run the dakweb server and also
+to provide the list_paths and path_help functions
+
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@copyright: 2014 Mark Hymers <mhy@debian.org>
+@license: GNU General Public License version 2 or later
+"""
-from sqlalchemy import or_
import bottle
-from daklib.dbconn import DBConn, DBSource, Suite, DSCFile, PoolFile
+from bottle import redirect
+from daklib.dbconn import DBConn
import json
from dakweb.webregister import QueryRegister
+
@bottle.route('/')
def root_path():
"""Returns a useless welcome message"""
return json.dumps('Use the /list_paths path to list all available paths')
QueryRegister().register_path('/', root_path)
+
@bottle.route('/list_paths')
def list_paths():
"""Returns a list of available paths"""
return json.dumps(QueryRegister().get_paths())
QueryRegister().register_path('/list_paths', list_paths)
+
@bottle.route('/path_help/<path>')
def path_help(path=None):
-
+ """Redirects to the API description containing the path_help"""
if path is None:
return bottle.HTTPError(503, 'Path not specified.')
- return json.dumps(QueryRegister().get_path_help(path))
+ redirect("https://ftp-master.debian.org/epydoc/%s-module.html#%s" %
+ (QueryRegister().get_path_help(path), path))
QueryRegister().register_path('/path_help', list_paths)
# Import our other methods
#!/usr/bin/python
+""" Archive related queries
+
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@copyright: 2014 Mark Hymers <mhy@debian.org>
+@license: GNU General Public License version 2 or later
+"""
+
import bottle
import json
from daklib.dbconn import DBConn, Archive
from dakweb.webregister import QueryRegister
+
@bottle.route('/archives')
def archives():
"""
- archives()
-
- returns: list of dictionaries
-
Give information about all known archives (sets of suites)
+
+ @rtype: dict
+ return: list of dictionaries
"""
s = DBConn().session()
return json.dumps(ret)
QueryRegister().register_path('/archives', archives)
-
+""" "Madison" interface
+
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@copyright: 2014 Ansgar Burchardt <ansgar@debian.org>
+@copyright: 2014 Joerg Jaspert <joerg@debian.org>
+@license: GNU General Public License version 2 or later
+"""
+
import bottle
import json
@bottle.route('/madison')
def madison():
"""
- Display information about packages.
+ Display information about B{package(s)}.
+
+ @since: December 2014
+
+ @keyword package: Space seperated list of packages.
+ @keyword b: only show info for a binary type. I{deb/udeb/dsc}
+ @keyword c: only show info for specified component(s). I{main/contrib/non-free}
+ @keyword s: only show info for this suite.
+ @keyword S: show info for the binary children of source pkgs. I{true/false}
+ @keyword f: output json format. I{json}
+ @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites.
- b=TYPE only show info for binary TYPE
- c=COMPONENT only show info for COMPONENT(s)
- s=SUITE only show info for this suite
- S=true show info for the binary children of source pkgs
- f=json output json format
+ @rtype: text/plain or application/json
+ @return: Text or Json format of the data
"""
r = bottle.request
-#!/usr/bin/python
+""" Queries related to source packages
+
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@copyright: 2014 Mark Hymers <mhy@debian.org>
+@copyright: 2014 Joerg Jaspert <joerg@debian.org>
+@license: GNU General Public License version 2 or later
+"""
from sqlalchemy import or_
import bottle
from daklib.dbconn import DBConn, DBSource, Suite, DSCFile, PoolFile
from dakweb.webregister import QueryRegister
+
@bottle.route('/dsc_in_suite/<suite>/<source>')
def dsc_in_suite(suite=None, source=None):
"""
- dsc_in_suite(suite, source)
+ Find all dsc files for a given source package name in a given suite.
- returns: list of dictionaries
+ @since: December 2014
- Find all dsc files for a given source package name in a given suite.
+ @type suite: string
+ @param suite: Name of the suite.
+ @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites.
+
+ @type source: string
+ @param source: Source package to query for.
+
+ @rtype: list of dictionaries
+ @return: Dictionaries made out of
+ - version
+ - component
+ - filename
+ - filesize
+ - sha256sum
"""
if suite is None:
return bottle.HTTPError(503, 'Suite not specified.')
@bottle.route('/sources_in_suite/<suite>')
def sources_in_suite(suite=None):
"""
- sources_in_suite(suite)
+ Returns all source packages and their versions in a given suite.
- returns: list of dictionaries
+ @since: December 2014
- Returns all source packages and their versions in a given suite.
- """
+ @type suite: string
+ @param suite: Name of the suite.
+ @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites.
+ @rtype: list of dictionaries
+ @return: Dictionaries made out of
+ - source
+ - version
+ """
if suite is None:
return bottle.HTTPError(503, 'Suite not specified.')
@bottle.route('/all_sources')
def all_sources():
"""
- all_sources()
-
- returns: list of dictionaries
-
Returns all source packages and their versions known to the archive
(this includes NEW).
+
+ @rtype: list of dictionaries
+ @return: Dictionaries made out of
+ - source
+ - version
"""
s = DBConn().session()
-#!/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
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.
- Give information about all known suites.
+ @rtype: list of dictionaries
+ @return: Dictionaries made out of
+ - name
+ - codename
+ - dakname
+ - archive
+ - architectures
+ - components
- name maps to Suite: in the release file
- codename maps to Codename: in the release file.
- dakname is an internal name and should not be relied upon.
"""
s = DBConn().session()
@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:
return json.dumps(so)
QueryRegister().register_path('/suite', suite)
-
+"""
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@copyright: 2014 Mark Hymers <mhy@debian.org>
+@license: GNU General Public License version 2 or later
+"""
+
class QueryRegister(object):
__shared_state = {}
self.queries = {}
def register_path(self, path, func):
- self.queries[path] = func.__doc__
+ self.queries[path] = func.__module__
def get_paths(self):
return sorted(self.queries.keys())
# We always register with the leading /
if not path.startswith('/'):
path = '/' + path
- return self.queries.get(path, 'Unknown path')
+ return self.queries.get(path, '/')
__all__ = ['QueryRegister']