1# Copyright 2020 The Distro Tracker Developers 

2# See the COPYRIGHT file at the top-level directory of this distribution and 

3# at https://deb.li/DTAuthors 

4# 

5# This file is part of Distro Tracker. It is subject to the license terms 

6# in the LICENSE file found in the top-level directory of this 

7# distribution and at https://deb.li/DTLicense. No part of Distro Tracker, 

8# including this file, may be copied, modified, propagated, or distributed 

9# except according to the terms contained in the LICENSE file. 

10""" 

11Utilities for generating URLs of various kinds 

12""" 

13 

14from django.utils.http import urlencode 

15 

16 

17def RepologyUrl(target_page, repo, package): 

18 """Build a repology.org URL""" 

19 query = urlencode({ 

20 'name_type': 'srcname', 

21 'noautoresolve': 'on', 

22 'repo': repo, 

23 'target_page': target_page, 

24 'name': package, 

25 }) 

26 return 'https://repology.org/tools/project-by?' + query 

27 

28 

29def RepologyVersionsUrl(repo, package): 

30 """Build a repology.org URL for the project_versions page""" 

31 return RepologyUrl('project_versions', repo, package) 

32 

33 

34def RepologyPackagesUrl(repo, package): 

35 """Build a repology.org URL for the project_packages page""" 

36 return RepologyUrl('project_packages', repo, package)