X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dakweb%2Fqueries%2Fsource.py;h=957cb0cc7c9169ae1189d672204c83c516ab8b04;hb=e41ae8d5a5fd9c204711a36b47e0593312da8c75;hp=925435b132f157bc912da40fcdd07ac8e16c25eb;hpb=adedbaadd3fb7468c894ba94595950c41bb61050;p=dak.git diff --git a/dakweb/queries/source.py b/dakweb/queries/source.py index 925435b1..957cb0cc 100755 --- a/dakweb/queries/source.py +++ b/dakweb/queries/source.py @@ -1,4 +1,10 @@ -#!/usr/bin/python +""" Queries related to source packages + +@contact: Debian FTPMaster +@copyright: 2014 Mark Hymers +@copyright: 2014 Joerg Jaspert +@license: GNU General Public License version 2 or later +""" from sqlalchemy import or_ import bottle @@ -7,14 +13,28 @@ import json from daklib.dbconn import DBConn, DBSource, Suite, DSCFile, PoolFile from dakweb.webregister import QueryRegister + @bottle.route('/dsc_in_suite//') 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}} 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.') @@ -45,13 +65,19 @@ QueryRegister().register_path('/dsc_in_suite', dsc_in_suite) @bottle.route('/sources_in_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}} 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.') @@ -68,3 +94,29 @@ def sources_in_suite(suite=None): return json.dumps(ret) QueryRegister().register_path('/sources_in_suite', sources_in_suite) + + +@bottle.route('/all_sources') +def all_sources(): + """ + 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() + q = s.query(DBSource) + ret = [] + for p in q: + ret.append({'source': p.source, + 'version': p.version}) + + s.close() + + return json.dumps(ret) + +QueryRegister().register_path('/all_sources', all_sources)