Skip to content

Commit c411545

Browse files
committed
Update license list
Also: * update main branch name of license repo * update list of public domain licenses * try to ensure disposal of 'http.client.HTTPResponse' objects by wrapping requests in a 'with' block * amend the generic copyright regex to include ellipses (...) as they appear in the full text of the Boehm-GC, for example
1 parent 40664b0 commit c411545

File tree

3 files changed

+89
-42
lines changed

3 files changed

+89
-42
lines changed

doc/cpywrite.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ REFERENCES *cpywrite-references*
263263
+-------------------------------------------------------------+-------------------+
264264
| Open Data Commons Public Domain Dedication & License 1.0 | PDDL-1.0 |
265265
+-------------------------------------------------------------+-------------------+
266+
| Sax Public Domain Notice | SAX-PD |
267+
+-------------------------------------------------------------+-------------------+
268+
| SGP4 Permission Notice | SGP4 |
269+
+-------------------------------------------------------------+-------------------+
266270
| The Unlicense | Unlicense |
267271
+-------------------------------------------------------------+-------------------+
268272

rplugin/python3/cpywrite/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _apply_format(text, pattern, author, email, year):
126126
# e.g. https://spdx.org/licenses/0BSD.html
127127
# This prevents faulty matches with the FSF ZIP code in the GPL v1 and 2
128128
author_date_re = \
129-
r'(?!.*(http).*)[\<\(\[\s%s]((YEAR)%s|[YX]+)[\>\)\]\s,-].+[\>\)\]\w+]' \
129+
r'(?!.*(http).*)(\.{3,}|[\<\(\[\s%s]((YEAR)%s|[YX]+)[\>\)\]\s,-].+[\>\)\]\w+])' \
130130
% ((r'\d', r'|\d{3}') \
131131
if self.rights.spdx_code == '0BSD' \
132132
else ('', '')) \

rplugin/python3/cpywrite/spdx/license.py

Lines changed: 84 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"""
66
import os
77
import tempfile
8-
import http.client as client
98
import xml.etree.ElementTree as parser
9+
from http import client
1010
from itertools import dropwhile
1111
from re import search, sub
1212
from sys import stderr
@@ -37,7 +37,7 @@ def header(self):
3737
return ''
3838

3939
xml_resource = 'https://raw.githubusercontent.com/' \
40-
'spdx/license-list-XML/master/src/%s.xml'
40+
'spdx/license-list-XML/main/src/%s.xml'
4141
resource = quote(xml_resource % self.spdx_code, safe='/:')
4242
license_data = None
4343
cache = _find_cached_license(self.spdx_code)
@@ -139,25 +139,47 @@ def license_text(self):
139139
return ''
140140

141141
# TODO: find a more reliable license generator: # pylint: disable=W0511
142-
# https://github.com/spdx/license-list-data/blob/master/text/MIT.txt
143-
# https://github.com/spdx/license-list-data/blob/master/text/0BSD.txt
142+
# https://github.com/spdx/license-list-data/blob/main/text/MIT.txt
143+
# https://github.com/spdx/license-list-data/blob/main/text/0BSD.txt
144144
# https://github.com/spdx/license-list-data/blob/2e20899c0504ff6c0acfcc1b0994d7163ce46939/text/Unlicense.txt#L10
145145
# https://github.com/spdx/license-list-data/blob/2e20899c0504ff6c0acfcc1b0994d7163ce46939/text/BSD-1-Clause.txt#L9
146146
#
147147
# full text of new licenses added since v3.11 are fetched from
148148
# the HEAD of spdx/license-list-data; USE THEM AT YOUR OWN RISK
149149
spdx_revision = '2e20899c0504ff6c0acfcc1b0994d7163ce46939' \
150150
if not self.spdx_code in [
151+
'AdaCore-doc',
152+
'ASWF-Digital-Assets-1.0',
153+
'ASWF-Digital-Assets-1.1',
154+
'Boehm-GC',
151155
'BSD-3-Clause-Modification',
152156
'BSD-3-Clause-No-Military-License',
153157
'BSD-4-Clause-Shortened',
154158
'C-UDA-1.0',
159+
'CC-BY-SA-3.0-IGO',
155160
'DRL-1.0',
161+
'dtoa',
156162
'FreeBSD-DOC',
157163
'GD',
164+
'Inner-Net-2.0',
165+
'Latex2e-translated-notice',
166+
'Linux-man-pages-1-para',
167+
'Linux-man-pages-copyleft-2-para',
168+
'Linux-man-pages-copyleft-var',
169+
'metamail',
158170
'MIT-Modern-Variant',
159-
'OGDL-Taiwan-1.0'] \
160-
else 'master'
171+
'MIT-Festival',
172+
'NIST-Software',
173+
'OGDL-Taiwan-1.0',
174+
'OLFL-1.3',
175+
'OPL-UK-3.0',
176+
'SGP4',
177+
'TermReadKey',
178+
'UnixCrypt',
179+
'Widget-Workshop',
180+
'Xdebug-1.03',
181+
'Xfig'] \
182+
else 'main'
161183

162184
text_resource = 'https://raw.githubusercontent.com/' \
163185
'spdx/license-list-data/' + spdx_revision + \
@@ -272,37 +294,36 @@ def _fetch_license(resource, spdx_id):
272294
_, ext = os.path.splitext(resource)
273295

274296
try:
275-
response = request.urlopen(request.Request(resource))
297+
with request.urlopen(request.Request(resource)) as response:
298+
if response.status == 200:
299+
response_text = response.read().decode('utf8')
300+
if ext.lower() == '.xml':
301+
try:
302+
license_data = parser.fromstring(response_text)
303+
except (client.IncompleteRead, parser.ParseError, TypeError):
304+
print("Got invalid licence data from %s." % (resource),
305+
file=stderr)
306+
else:
307+
license_data = response_text
276308

277-
if response.status == 200:
278-
response_text = response.read().decode('utf8')
279-
if ext.lower() == '.xml':
280309
try:
281-
license_data = parser.fromstring(response_text)
282-
except (client.IncompleteRead, parser.ParseError, TypeError):
283-
print("Got invalid licence data from %s." % (resource),
284-
file=stderr)
310+
_, temp_file = \
311+
tempfile.mkstemp(prefix=spdx_id + '_',
312+
suffix=ext,
313+
text=True)
314+
if temp_file:
315+
try:
316+
with open(temp_file, 'w', encoding='utf-8') as tmp:
317+
tmp.write(response_text)
318+
except IOError:
319+
pass
320+
321+
except IOError:
322+
pass
285323
else:
286-
license_data = response_text
287-
288-
try:
289-
_, temp_file = \
290-
tempfile.mkstemp(prefix=spdx_id + '_',
291-
suffix=ext,
292-
text=True)
293-
if temp_file:
294-
try:
295-
with open(temp_file, 'w', encoding='utf-8') as tmp:
296-
tmp.write(response_text)
297-
except IOError:
298-
pass
299-
300-
except IOError:
301-
pass
302-
else:
303-
print("Unexpected response [%d] from %s.\n"
304-
% (response.status_code, resource),
305-
file=stderr)
324+
print("Unexpected response [%d] from %s.\n"
325+
% (response.status_code, resource),
326+
file=stderr)
306327

307328
except (urllib_error.HTTPError,
308329
urllib_error.URLError):
@@ -314,6 +335,7 @@ def _fetch_license(resource, spdx_id):
314335
'0BSD',
315336
'AAL',
316337
'Abstyles',
338+
'AdaCore-doc',
317339
'Adobe-2006',
318340
'Adobe-Glyph',
319341
'ADSL',
@@ -346,13 +368,16 @@ def _fetch_license(resource, spdx_id):
346368
'Artistic-1.0-cl8',
347369
'Artistic-1.0-Perl',
348370
'Artistic-2.0',
371+
'ASWF-Digital-Assets-1.0',
372+
'ASWF-Digital-Assets-1.1',
349373
'Bahyph',
350374
'Barr',
351375
'Beerware',
352376
'BitTorrent-1.0',
353377
'BitTorrent-1.1',
354378
'blessing',
355379
'BlueOak-1.0.0',
380+
'Boehm-GC',
356381
'Borceux',
357382
'BSD-1-Clause',
358383
'BSD-2-Clause',
@@ -377,11 +402,11 @@ def _fetch_license(resource, spdx_id):
377402
'BUSL-1.1',
378403
'bzip2-1.0.5',
379404
'bzip2-1.0.6',
380-
'C-UDA-1.0',
381405
'CAL-1.0',
382406
'CAL-1.0-Combined-Work-Exception',
383407
'Caldera',
384408
'CATOSL-1.1',
409+
'CC0-1.0',
385410
'CC-BY-1.0',
386411
'CC-BY-2.0',
387412
'CC-BY-2.5',
@@ -416,9 +441,9 @@ def _fetch_license(resource, spdx_id):
416441
'CC-BY-SA-2.5',
417442
'CC-BY-SA-3.0',
418443
'CC-BY-SA-3.0-AT',
444+
'CC-BY-SA-3.0-IGO',
419445
'CC-BY-SA-4.0',
420446
'CC-PDDC',
421-
'CC0-1.0',
422447
'CDDL-1.0',
423448
'CDDL-1.1',
424449
'CDLA-Permissive-1.0',
@@ -448,13 +473,15 @@ def _fetch_license(resource, spdx_id):
448473
'CrystalStacker',
449474
'CUA-OPL-1.0',
450475
'Cube',
476+
'C-UDA-1.0',
451477
'curl',
452478
'D-FSL-1.0',
453479
'diffmark',
454480
'DOC',
455481
'Dotseqn',
456482
'DRL-1.0',
457483
'DSDP',
484+
'dtoa',
458485
'dvipdfm',
459486
'ECL-1.0',
460487
'ECL-2.0',
@@ -523,6 +550,7 @@ def _fetch_license(resource, spdx_id):
523550
'iMatix',
524551
'Imlib2',
525552
'Info-ZIP',
553+
'Inner-Net-2.0',
526554
'Intel',
527555
'Intel-ACPI',
528556
'Interbase-1.0',
@@ -535,6 +563,7 @@ def _fetch_license(resource, spdx_id):
535563
'LAL-1.2',
536564
'LAL-1.3',
537565
'Latex2e',
566+
'Latex2e-translated-notice',
538567
'Leptonica',
539568
'LGPL-2.0-only',
540569
'LGPL-2.0-or-later',
@@ -550,6 +579,9 @@ def _fetch_license(resource, spdx_id):
550579
'LiLiQ-P-1.1',
551580
'LiLiQ-R-1.1',
552581
'LiLiQ-Rplus-1.1',
582+
'Linux-man-pages-1-para',
583+
'Linux-man-pages-copyleft-2-para',
584+
'Linux-man-pages-copyleft-var',
553585
'Linux-OpenIB',
554586
'LPL-1.0',
555587
'LPL-1.02',
@@ -559,16 +591,18 @@ def _fetch_license(resource, spdx_id):
559591
'LPPL-1.3a',
560592
'LPPL-1.3c',
561593
'MakeIndex',
594+
'metamail',
562595
'MirOS',
563596
'MIT',
564597
'MIT-0',
565598
'MIT-advertising',
566599
'MIT-CMU',
567600
'MIT-enna',
568601
'MIT-feh',
602+
'MIT-Festival',
569603
'MIT-Modern-Variant',
570-
'MIT-open-group',
571604
'MITNFA',
605+
'MIT-open-group',
572606
'Motosoto',
573607
'mpich2',
574608
'MPL-1.0',
@@ -587,12 +621,13 @@ def _fetch_license(resource, spdx_id):
587621
'NBPL-1.0',
588622
'NCGL-UK-2.0',
589623
'NCSA',
590-
'Net-SNMP',
591624
'NetCDF',
625+
'Net-SNMP',
592626
'Newsletr',
593627
'NGPL',
594628
'NIST-PD',
595629
'NIST-PD-fallback',
630+
'NIST-Software',
596631
'NLOD-1.0',
597632
'NLPL',
598633
'Nokia',
@@ -604,7 +639,6 @@ def _fetch_license(resource, spdx_id):
604639
'NRL',
605640
'NTP',
606641
'NTP-0',
607-
'O-UDA-1.0',
608642
'OCCT-PL',
609643
'OCLC-2.0',
610644
'ODbL-1.0',
@@ -638,15 +672,18 @@ def _fetch_license(resource, spdx_id):
638672
'OLDAP-2.6',
639673
'OLDAP-2.7',
640674
'OLDAP-2.8',
675+
'OLFL-1.3',
641676
'OML',
642677
'OpenSSL',
643678
'OPL-1.0',
679+
'OPL-UK-3.0',
644680
'OSET-PL-2.1',
645681
'OSL-1.0',
646682
'OSL-1.1',
647683
'OSL-2.0',
648684
'OSL-2.1',
649685
'OSL-3.0',
686+
'O-UDA-1.0',
650687
'Parity-6.0.0',
651688
'Parity-7.0.0',
652689
'PDDL-1.0',
@@ -670,14 +707,15 @@ def _fetch_license(resource, spdx_id):
670707
'RSA-MD',
671708
'RSCPL',
672709
'Ruby',
673-
'SAX-PD',
674710
'Saxpath',
711+
'SAX-PD',
675712
'SCEA',
676713
'Sendmail',
677714
'Sendmail-8.23',
678715
'SGI-B-1.0',
679716
'SGI-B-1.1',
680717
'SGI-B-2.0',
718+
'SGP4',
681719
'SHL-0.5',
682720
'SHL-0.51',
683721
'SimPL-2.0',
@@ -699,6 +737,7 @@ def _fetch_license(resource, spdx_id):
699737
'TAPR-OHL-1.0',
700738
'TCL',
701739
'TCP-wrappers',
740+
'TermReadKey',
702741
'TMate',
703742
'TORQUE-1.1',
704743
'TOSL',
@@ -708,6 +747,7 @@ def _fetch_license(resource, spdx_id):
708747
'Unicode-DFS-2015',
709748
'Unicode-DFS-2016',
710749
'Unicode-TOU',
750+
'UnixCrypt',
711751
'Unlicense',
712752
'UPL-1.0',
713753
'Vim',
@@ -717,10 +757,13 @@ def _fetch_license(resource, spdx_id):
717757
'W3C-19980720',
718758
'W3C-20150513',
719759
'Watcom-1.0',
760+
'Widget-Workshop',
720761
'Wsuipa',
721762
'WTFPL',
722763
'X11',
764+
'Xdebug-1.03',
723765
'Xerox',
766+
'Xfig',
724767
'XFree86-1.1',
725768
'xinetd',
726769
'Xnet',
@@ -744,7 +787,7 @@ def _fetch_license(resource, spdx_id):
744787
_PD_LICENSE_IDS = [
745788
'ANTLR-PD', 'ANTLR-PD-fallback', 'CC-PDDC', 'CC0-1.0',
746789
'libselinux-1.0', 'NIST-PD', 'NIST-PD-fallback', 'PDDL-1.0',
747-
'SAX-PD', 'Unlicense']
790+
'SAX-PD', 'SGP4', 'Unlicense']
748791
"""
749792
Licenses with no copyright requirement
750793
"""

0 commit comments

Comments
 (0)