Package: tracker.debian.org Severity: wishlist Tags: patch Dear Maintainer,
I would like to access to the copyright information of packages on the distro- tracker. Examples https://sources.debian.net/copyright/license/python-django/1.9.1-1/ https://sources.debian.net/copyright/license/gnubg/1.05.000-3/ I attach a patch that provides a link in the links panel -- System Information: Debian Release: 8.2 APT prefers testing APT policy: (1000, 'testing'), (1000, 'stable'), (995, 'stable'), (750, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system)
>From 015cf0331508af79cd2afea4ab384964347ba5d0 Mon Sep 17 00:00:00 2001 From: Orestis Ioannou <ores...@oioannou.com> Date: Sat, 2 Jan 2016 14:36:46 +0200 Subject: [PATCH] Provide link to debsources copyright tracker --- distro_tracker/vendor/debian/tests.py | 13 ++++++++++++- distro_tracker/vendor/debian/tracker_panels.py | 10 ++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/distro_tracker/vendor/debian/tests.py b/distro_tracker/vendor/debian/tests.py index 5757b41..c641cad 100644 --- a/distro_tracker/vendor/debian/tests.py +++ b/distro_tracker/vendor/debian/tests.py @@ -2738,7 +2738,14 @@ class CodeSearchLinksTest(TestCase): def browse_link_in_content(self, content): html = soup(content) for a_tag in html.findAll('a', {'href': True}): - if a_tag['href'].startswith('https://sources.debian.net'): + if a_tag['href'].startswith('https://sources.debian.net/src'): + return True + return False + + def copyright_link_in_content(self, content): + html = soup(content) + for a_tag in html.findAll('a', {'href': True}): + if a_tag['href'].startswith('https://sources.debian.net/copyright'): return True return False @@ -2757,6 +2764,7 @@ class CodeSearchLinksTest(TestCase): response = self.get_package_page_response(self.package.name) self.assertTrue(self.browse_link_in_content(response.content)) + self.assertTrue(self.copyright_link_in_content(response.content)) self.assertFalse(self.search_form_in_content(response.content)) def test_package_not_in_allowed_repository(self): @@ -2771,6 +2779,7 @@ class CodeSearchLinksTest(TestCase): response = self.get_package_page_response(self.package.name) self.assertFalse(self.browse_link_in_content(response.content)) + self.assertFalse(self.copyright_link_in_content(response.content)) self.assertFalse(self.search_form_in_content(response.content)) def test_package_in_unstable(self): @@ -2784,6 +2793,7 @@ class CodeSearchLinksTest(TestCase): response_content = response.content.decode('utf-8') self.assertTrue(self.browse_link_in_content(response_content)) + self.assertTrue(self.copyright_link_in_content(response_content)) self.assertTrue(self.search_form_in_content(response_content)) def test_pseudo_package(self): @@ -2797,6 +2807,7 @@ class CodeSearchLinksTest(TestCase): response_content = response.content.decode('utf-8') self.assertFalse(self.browse_link_in_content(response_content)) + self.assertFalse(self.copyright_link_in_content(response_content)) self.assertFalse(self.search_form_in_content(response_content)) def test_code_search_view_missing_query_parameter(self): diff --git a/distro_tracker/vendor/debian/tracker_panels.py b/distro_tracker/vendor/debian/tracker_panels.py index 49ba680..35e3b2e 100644 --- a/distro_tracker/vendor/debian/tracker_panels.py +++ b/distro_tracker/vendor/debian/tracker_panels.py @@ -132,7 +132,9 @@ class SourceCodeSearchLinks(LinksPanel.ItemProvider): 'stable', 'oldstable', ) - SOURCES_URL_TEMPLATE = 'https://sources.debian.net/src/{package}/{suite}/' + DEBSOURCES = 'https://sources.debian.net/' + SOURCES_TEMPLATE = DEBSOURCES + 'src/{package}/{suite}/' + COPYRIGHT_TEMPLATE = DEBSOURCES + 'copyright/license/{package}/{suite}/' SEARCH_FORM_TEMPLATE = ( '<form class="code-search-form"' ' action="' + reverse('dtracker-code-search') + '"' @@ -152,8 +154,12 @@ class SourceCodeSearchLinks(LinksPanel.ItemProvider): for allowed_repo in self.ALLOWED_REPOSITORIES: if allowed_repo in repositories: links.append(LinksPanel.SimpleLinkItem( + 'view copyright', + self.COPYRIGHT_TEMPLATE.format( + package=self.package.name, suite=allowed_repo))) + links.append(LinksPanel.SimpleLinkItem( 'browse source code', - self.SOURCES_URL_TEMPLATE.format( + self.SOURCES_TEMPLATE.format( package=self.package.name, suite=allowed_repo))) break -- 2.1.4