1"""Archive related queries 

2 

3@contact: Debian FTPMaster <ftpmaster@debian.org> 

4@copyright: 2014 Mark Hymers <mhy@debian.org> 

5@license: GNU General Public License version 2 or later 

6""" 

7 

8import json 

9 

10import bottle 

11 

12from daklib.dbconn import Archive, DBConn 

13from dakweb.webregister import QueryRegister 

14 

15 

16@bottle.route("/archives") 

17def archives() -> str: 

18 """ 

19 Give information about all known archives (sets of suites) 

20 

21 :return: list of dictionaries 

22 """ 

23 

24 s = DBConn().session() 

25 q = s.query(Archive) 

26 q = q.order_by(Archive.archive_name) 

27 ret = [] 

28 for a in q: 

29 ret.append({"name": a.archive_name, "suites": [x.suite_name for x in a.suites]}) 

30 

31 s.close() 

32 

33 bottle.response.content_type = "application/json; charset=UTF-8" 

34 return json.dumps(ret) 

35 

36 

37QueryRegister().register_path("/archives", archives)