Skip to content

Commit 77f7358

Browse files
committed
Update script to work with latest SPDX and DejaCode
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 16011be commit 77f7358

1 file changed

Lines changed: 31 additions & 28 deletions

File tree

etc/scripts/synclic.py

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright (c) 2017 nexB Inc. and others. All rights reserved.
3+
# Copyright (c) 2019 nexB Inc. and others. All rights reserved.
44
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
55
# The ScanCode software is licensed under the Apache License version 2.0.
66
# Data generated with ScanCode require an acknowledgment.
@@ -56,9 +56,9 @@
5656
- the DejaCode licenses
5757
5858
Run python synclic.py -h for help.
59-
6059
"""
6160

61+
6262
TRACE = True
6363
TRACE_ADD = True
6464
TRACE_FETCH = True
@@ -434,10 +434,6 @@ def build_license(self, mapping, scancode_licenses):
434434

435435
other_urls = list(other_urls)
436436

437-
# notes = mapping.get('licenseComments')
438-
# if notes and notes.strip():
439-
# notes = 'Per SPDX.org, ' + ' '.join(notes.split())
440-
441437
standard_notice = mapping.get('standardLicenseHeader') or ''
442438
if standard_notice:
443439
standard_notice = clean_text(standard_notice)
@@ -545,11 +541,7 @@ def build_license(self, mapping, scancode_licenses):
545541
# these licenses are combos of many others and are ignored: we detect
546542
# instead each part of the combo
547543
dejacode_special_composites = set([
548-
'lzma-sdk-2006',
549-
'intel-bsd-special',
550-
'openssh',
551-
'aes-128-3.0',
552-
'stlport-2000',
544+
'intel-bsd-special',
553545
])
554546
is_combo = key in dejacode_special_composites
555547
if is_combo:
@@ -772,27 +764,35 @@ def license_to_dict(lico):
772764
Return an OrderedDict of license data with texts for API calls.
773765
Fields with empty values are not included.
774766
"""
775-
return dict(
767+
licm = dict(
776768
is_active=False,
777769
reviewed=False,
778770
license_status='NotReviewed',
779771
is_component_license=False,
780-
781772
key=lico.key,
782773
short_name=lico.short_name,
783774
name=lico.name,
784775
category=lico.category,
785776
owner=lico.owner,
786-
homepage_url=lico.homepage_url,
787-
reference_notes=lico.notes,
788-
full_text=lico.text,
789-
is_exception=lico.is_exception,
790-
spdx_license_key=lico.spdx_license_key,
791-
text_urls='\n'.join(lico.text_urls),
792-
osi_url=lico.osi_url,
793-
faq_url=lico.faq_url,
794-
other_urls='\n'.join(lico.other_urls),
777+
is_exception=lico.is_exception
795778
)
779+
if lico.text:
780+
licm.update(full_text=lico.text)
781+
if lico.homepage_url:
782+
licm.update(homepage_url=lico.homepage_url)
783+
if lico.spdx_license_key:
784+
licm.update(spdx_license_key=lico.spdx_license_key)
785+
if lico.notes:
786+
licm.update(reference_notes=lico.notes)
787+
if lico.text_urls:
788+
licm.update(text_urls='\n'.join(lico.text_urls))
789+
if lico.osi_url:
790+
licm.update(osi_url=lico.osi_url)
791+
if lico.faq_url:
792+
licm.update(faq_url=lico.faq_url)
793+
if lico.other_urls:
794+
licm.update(other_urls='\n'.join(lico.other_urls))
795+
return licm
796796

797797

798798
EXTERNAL_LICENSE_SYNCHRONIZATION_SOURCES = {
@@ -863,12 +863,15 @@ def update_external(_attrib, _sc_val, _ext_val):
863863
# special case for URL lists, we consider all URL fields to
864864
# update
865865
if attrib.endswith('_urls',):
866-
all_sc_urls = set(list(normalized_scancode_value)
867-
+scancode_license.text_urls
868-
+scancode_license.other_urls
869-
+[scancode_license.homepage_url,
870-
scancode_license.osi_url,
871-
scancode_license.faq_url])
866+
all_sc_urls = set(
867+
list(normalized_scancode_value) +
868+
scancode_license.text_urls +
869+
scancode_license.other_urls +
870+
[scancode_license.homepage_url,
871+
scancode_license.osi_url,
872+
scancode_license.faq_url
873+
]
874+
)
872875
all_sc_urls = set(u for u in all_sc_urls if u)
873876
new_other_urls = normalize_external_value.difference(all_sc_urls)
874877
# add other urls to ScanCode

0 commit comments

Comments
 (0)