X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dakweb%2Fqueries%2Fmadison.py;h=9678a36ebeb021fd818ab68401bf6c445b544809;hb=c4a632e83afddddc51fe62927c343e9b54f6f69c;hp=469f9c80d304e10c0c2d7ef614d84e62572023cf;hpb=59d33fca226689f0b8972463bf25f148bf3d7a71;p=dak.git diff --git a/dakweb/queries/madison.py b/dakweb/queries/madison.py index 469f9c80..9678a36e 100644 --- a/dakweb/queries/madison.py +++ b/dakweb/queries/madison.py @@ -6,6 +6,16 @@ from dakweb.webregister import QueryRegister @bottle.route('/madison') def madison(): + """ + Display information about packages. + + 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 + """ + r = bottle.request packages = r.query.get('package', '').split() @@ -24,8 +34,19 @@ def madison(): kwargs['source_and_binary'] = True #if 'r' in r.query: # kwargs['regex'] = True + format = r.query.get('f', None) + if format is not None: + kwargs['format'] = 'python' result = list_packages(packages, **kwargs) - return "\n".join(result) + "\n" + + if format is None: + bottle.response.content_type = 'text/plain' + for row in result: + yield row + yield "\n" + else: + yield json.dumps(list(result)) + QueryRegister().register_path('/madison', madison)