Package dakweb :: Package queries :: Module madison
[hide private]
[frames] | no frames]

Source Code for Module dakweb.queries.madison

 1  """ "Madison" interface 
 2   
 3  @contact: Debian FTPMaster <ftpmaster@debian.org> 
 4  @copyright: 2014  Ansgar Burchardt <ansgar@debian.org> 
 5  @copyright: 2014  Joerg Jaspert <joerg@debian.org> 
 6  @license: GNU General Public License version 2 or later 
 7  """ 
 8   
 9  import bottle 
10  import json 
11   
12  from daklib.ls import list_packages 
13  from dakweb.webregister import QueryRegister 
14 15 16 @bottle.route('/madison') 17 -def madison():
18 """ 19 Display information about B{package(s)}. 20 21 @since: December 2014 22 23 @keyword package: Space separated list of packages. 24 @keyword a: only show info for specified architectures. 25 @keyword b: only show info for a binary type. I{deb/udeb/dsc} 26 @keyword c: only show info for specified component(s). I{main/contrib/non-free} 27 @keyword s: only show info for this suite. 28 @keyword S: show info for the binary children of source pkgs. I{true/false} 29 @keyword f: output json format. I{json} 30 @see: L{I{suites}<dakweb.queries.suite.suites>} on how to receive a list of valid suites. 31 32 @rtype: text/plain or application/json 33 @return: Text or Json format of the data 34 """ 35 36 r = bottle.request 37 38 packages = r.query.get('package', '').split() 39 kwargs = dict() 40 41 architectures = r.query.get('a', None) 42 if architectures is not None: 43 kwargs['architectures'] = architectures.split(",") 44 binary_type = r.query.get('b', None) 45 if binary_type is not None: 46 kwargs['binary_types'] = [binary_type] 47 component = r.query.get('c', None) 48 if component is not None: 49 kwargs['components'] = component.split(",") 50 suite = r.query.get('s', None) 51 if suite is not None: 52 kwargs['suites'] = suite.split(",") 53 if 'S' in r.query: 54 kwargs['source_and_binary'] = True 55 format = r.query.get('f', None) 56 if format is not None: 57 kwargs['format'] = 'python' 58 59 result = list_packages(packages, **kwargs) 60 61 if format is None: 62 bottle.response.content_type = 'text/plain; charset=UTF-8' 63 for row in result: 64 yield row 65 yield "\n" 66 else: 67 bottle.response.content_type = 'application/json; charset=UTF-8' 68 yield json.dumps(list(result))
69 70 71 QueryRegister().register_path('/madison', madison) 72