Skip to content

Commit 676a471

Browse files
committed
Generate correct URLs for license and rules
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 2548f43 commit 676a471

File tree

133 files changed

+605
-620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+605
-620
lines changed

src/licensedcode/models.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,29 +368,33 @@ def from_dir(cls, key, licenses_data_dir=licenses_data_dir, check_consistency=Tr
368368

369369
@property
370370
def scancode_url(self):
371-
return SCANCODE_LICENSE_URL.format(self.key)
371+
if self.is_builtin:
372+
return SCANCODE_LICENSE_URL.format(self.key)
372373

373374
@property
374375
def licensedb_url(self):
375-
return SCANCODE_LICENSEDB_URL.format(self.key)
376+
if self.is_builtin:
377+
return SCANCODE_LICENSEDB_URL.format(self.key)
376378

377379
@property
378380
def spdx_url(self):
379381
"""
380382
Return a URL to the SPDX license either at SPDX, ScanCode or None.
381383
"""
382-
spdx_license_key = self.spdx_license_key
383-
if not spdx_license_key:
384-
return
384+
if self.is_builtin:
385+
spdx_license_key = self.spdx_license_key
386+
if not spdx_license_key:
387+
return
385388

386-
is_license_ref = spdx_license_key.lower().startswith('licenseref-')
389+
slkl = spdx_license_key.lower()
390+
is_licenseref = slkl.startswith('licenseref-')
387391

388-
if is_license_ref:
389-
return SCANCODE_LICENSE_URL.format(self.key)
390-
else:
391-
# TODO: Is this replacing spdx_key???
392-
spdx_license_key = spdx_license_key.rstrip('+')
393-
return SPDX_LICENSE_URL.format(spdx_license_key)
392+
if is_licenseref:
393+
return SCANCODE_LICENSE_URL.format(self.key)
394+
else:
395+
# TODO: Is this replacing spdx_key???
396+
spdx_license_key = spdx_license_key.rstrip('+')
397+
return SPDX_LICENSE_URL.format(spdx_license_key)
394398

395399
def license_file(self, licenses_data_dir=licenses_data_dir):
396400
return join(licenses_data_dir, f'{self.key}.LICENSE')
@@ -462,8 +466,8 @@ def to_reference(self):
462466
# include everything
463467
data = self._to_dict(include_field=lambda k, v: True)
464468
data.pop('is_deprecated', None)
465-
data['scancode_url'] = self.spdx_url
466-
data['licensedb_url'] = self.spdx_url
469+
data['scancode_url'] = self.scancode_url
470+
data['licensedb_url'] = self.licensedb_url
467471
data['spdx_url'] = self.spdx_url
468472
return data
469473

tests/cluecode/data/plugin_filter_clues/filtered-expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
"apache@apache.org"
6868
],
6969
"text": "The Apache Software License, Version 1.1\n\nCopyright (c) 2000 The Apache Software Foundation. All rights\nreserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in\n the documentation and/or other materials provided with the\n distribution.\n\n3. The end-user documentation included with the redistribution,\n if any, must include the following acknowledgment:\n \"This product includes software developed by the\n Apache Software Foundation (http://www.apache.org/).\"\n Alternately, this acknowledgment may appear in the software itself,\n if and wherever such third-party acknowledgments normally appear.\n\n4. The names \"Apache\" and \"Apache Software Foundation\" must\n not be used to endorse or promote products derived from this\n software without prior written permission. For written\n permission, please contact apache@apache.org.\n\n5. Products derived from this software may not be called \"Apache\",\n nor may \"Apache\" appear in their name, without prior written\n permission of the Apache Software Foundation.\n\nTHIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED\nWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR\nITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\nUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGE.",
70-
"scancode_url": "https://spdx.org/licenses/Apache-1.1",
71-
"licensedb_url": "https://spdx.org/licenses/Apache-1.1",
70+
"scancode_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/apache-1.1.LICENSE",
71+
"licensedb_url": "https://scancode-licensedb.aboutcode.org/apache-1.1",
7272
"spdx_url": "https://spdx.org/licenses/Apache-1.1"
7373
}
7474
],

tests/cluecode/data/plugin_filter_clues/filtered-expected2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
],
6666
"text": "PyGres, version 2.2 A Python interface for PostgreSQL database. Written by\nD'Arcy J.M. Cain, (darcy@druid.net). Based heavily on code written by\nPascal Andre, andre@chimay.via.ecp.fr. Copyright (c) 1995, Pascal Andre\n(andre@via.ecp.fr).\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose, without fee, and without a written\nagreement is hereby granted, provided that the above copyright notice and\nthis paragraph and the following two paragraphs appear in all copies or in\nany new file that contains a substantial portion of this file.\n\nIN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,\nSPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,\nARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE\nAUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nTHE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN \"AS IS\" BASIS, AND THE\nAUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,\nENHANCEMENTS, OR MODIFICATIONS.\n\nFurther modifications copyright 1997, 1998, 1999 by D'Arcy J.M. Cain\n(darcy@druid.net) subject to the same terms and conditions as above.",
6767
"scancode_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/pygres-2.2.LICENSE",
68-
"licensedb_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/pygres-2.2.LICENSE",
68+
"licensedb_url": "https://scancode-licensedb.aboutcode.org/pygres-2.2",
6969
"spdx_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/pygres-2.2.LICENSE"
7070
}
7171
],

tests/cluecode/data/plugin_filter_clues/filtered-expected3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
],
6868
"text": "PCRE LICENCE \n------------ \n\nPCRE is a library of functions to support regular expressions whose\nsyntax and semantics are as close as possible to those of the Perl 5\nlanguage.\n\nWritten by: Philip Hazel <ph10@cam.ac.uk>\nUniversity of Cambridge Computing Service, Cambridge, England. \nPhone: +44 1223 334714.\nCopyright (c) 1997-2001 University of Cambridge\n\nPermission is granted to anyone to use this software for any purpose on\nany computer system, and to redistribute it freely, subject to the\nfollowing restrictions:\n\n1. This software is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n2. The origin of this software must not be misrepresented, either by\nexplicit claim or by omission. In practice, this means that if you use\nPCRE in software which you distribute to others, commercially or\notherwise, you must put a sentence like this\n\"Regular expression support is provided by the PCRE library package,\nwhich is open source software, written by Philip Hazel, and copyright by\nthe University of Cambridge, England\" \n\nsomewhere reasonably visible in your documentation and in any relevant\nfiles or online help data or similar.\n\nA reference to the ftp site for the source, that is, to\nftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ \nshould also be given in the documentation.\n\n3. Altered versions must be plainly marked as such, and must not be\nmisrepresented as being the original software.\n\n4. If PCRE is embedded in any software that is released under the GNU\nGeneral Purpose Licence (GPL), or Lesser General Purpose Licence (LGPL),\nthen the terms of that licence shall supersede any condition above with\nwhich it is incompatible.\n\nThe documentation for PCRE, supplied in the \"doc\" directory, is\ndistributed under the same terms as the software itself.\n\nEnd PCRE LICENCE",
6969
"scancode_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/pcre.LICENSE",
70-
"licensedb_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/pcre.LICENSE",
70+
"licensedb_url": "https://scancode-licensedb.aboutcode.org/pcre",
7171
"spdx_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/pcre.LICENSE"
7272
}
7373
],

tests/formattedcode/data/yaml/simple-expected.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ headers:
2626
platform_version: '#211~16.04.2-Ubuntu SMP Fri Nov 25 09:18:48 UTC 2022'
2727
python_version: "3.9.10 (main, Jan 29 2022, 10:01:49) \n[GCC 5.4.0 20160609]"
2828
spdx_license_list_version: '3.19'
29-
additional_license_plugins:
30-
- /home/pombreda/w421/scancode-toolkit-master5/venv/lib/python3.9/site-packages/licenses_to_install1
31-
- /home/pombreda/w421/scancode-toolkit-master5/venv/lib/python3.9/site-packages/licenses_to_install2
3229
files_count: 1
3330
packages: []
3431
dependencies: []

tests/formattedcode/data/yaml/tree/expected.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ headers:
2727
platform_version: '#211~16.04.2-Ubuntu SMP Fri Nov 25 09:18:48 UTC 2022'
2828
python_version: "3.9.10 (main, Jan 29 2022, 10:01:49) \n[GCC 5.4.0 20160609]"
2929
spdx_license_list_version: '3.19'
30-
OUTDATED: 'WARNING: Outdated ScanCode Toolkit version! You are using an outdated version
31-
of ScanCode Toolkit: 32.0.0rc1 released on: 2023-01-03. A new version 42.5.1 is available
32-
with important improvements including bug and security fixes, updated license, copyright
33-
and package detection, and improved scanning accuracy. Please download and install the
34-
latest version of ScanCode. Visit https://github.com/nexB/scancode-toolkit/releases
35-
for details.'
36-
additional_license_directory: /home/pombreda/w421/scancode-toolkit-master5/tests/licensedcode/data/additional_licenses/additional_dir
37-
additional_license_plugins:
38-
- /home/pombreda/w421/scancode-toolkit-master5/venv/lib/python3.9/site-packages/licenses_to_install1
39-
- /home/pombreda/w421/scancode-toolkit-master5/venv/lib/python3.9/site-packages/licenses_to_install2
4030
files_count: 7
4131
packages: []
4232
dependencies: []
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
license_expressions:
2-
- qt-commercial-1.1 OR lgpl-2.1 WITH qt-company-exception-lgpl-2.1 OR lgpl-3.0 WITH
3-
qt-company-exception-lgpl-2.1
4-
2+
- qt-commercial-1.1 OR lgpl-2.1 WITH qt-company-exception-lgpl-2.1 OR lgpl-3.0 WITH qt-company-exception-lgpl-2.1

tests/licensedcode/data/licenses_reference_reporting/license-reference-works-with-clues.expected.json

Lines changed: 21 additions & 21 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)