2 # SPDX-FileCopyrightText: 2020 kaliko <kaliko@azylum.org>
3 # SPDX-License-Identifier: GPL-3.0-or-later
8 from urllib.error import URLError, HTTPError
9 from urllib.request import Request, urlopen
10 from urllib.parse import urlencode
16 https://ftp-team.pages.debian.net/dak/epydoc/dakweb.queries.madison-module.html
18 logger = logging.getLogger(__package__)
22 values = urlencode(data)
23 url = f'https://api.ftp-master.debian.org/madison?{values}'
25 req = Request(url, method='GET')
27 response = urlopen(req)
29 except HTTPError as err:
30 logger.info('The server couldn\'t fulfill the request.')
31 logger.debug('Error code: %s', err.code)
32 except URLError as err:
33 logger.info('We failed to reach a server.')
34 logger.debug('Reason: %s', err.reason)
36 pkg_info = json.loads(ans)
37 except Exception as err:
38 logger.error('Failed to decode json')
41 return pkg_info[0][pkg]
45 if __name__ == '__main__':
49 # vim: ai ts=4 sw=4 sts=4 expandtab fileencoding=utf8