Skip to content

Commit 28baa7c

Browse files
committed
Fixed #133 - Use 'dje_license_key' instead of 'dje_license'
1 parent 1c9288d commit 28baa7c

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

about_code_tool/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def repr_problem(obj):
180180

181181
DJE_FIELDS = (
182182
'dje_component',
183-
'dje_license',
183+
'dje_license_key',
184184
'dje_organization',
185185
'dje_license_name'
186186
)

about_code_tool/genabout.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def request_license_data(self, url, username, api_key, license_key):
340340
username + '/' + api_key, error_msg))
341341
else:
342342
# FIXME: would this be only with a 404?
343-
self.errors.append(Error(VALUE, 'dje_license', license_key,
343+
self.errors.append(Error(VALUE, 'dje_license_key', license_key,
344344
"Invalid 'dje_license_key'"))
345345
except urllib2.URLError:
346346
if about.check_network_connection():
@@ -413,26 +413,26 @@ def get_dje_license_list(self, gen_location, input_list, gen_license, dje_licens
413413
self.errors.append(Error(FILE, 'license_text_file', license_file, "The 'license_text_file' does not exist."))
414414
else:
415415
if gen_license:
416-
if line['dje_license']:
416+
if line['dje_license_key']:
417417
license_output_list.append(self.gen_license_list(line))
418418
lic_name = line['dje_license_name']
419419
line['license_text_file'] = dje_license_dict[lic_name][0] + '.LICENSE'
420420
else:
421-
self.warnings.append(Warn(VALUE, 'dje_license', '',
422-
"Missing 'dje_license' for " + line['about_file']))
421+
self.warnings.append(Warn(VALUE, 'dje_license_key', '',
422+
"Missing 'dje_license_key' for " + line['about_file']))
423423
# This except condition will force the tool to create the
424424
# 'license_text_file' key column from the self.gen_license_list(line)
425425
except Exception:
426426
# FIXME: this is too complex
427427
if gen_license:
428-
if line['dje_license']:
428+
if line['dje_license_key']:
429429
license_output_list.append(self.gen_license_list(line))
430430
lic_name = line['dje_license_name']
431431
if lic_name:
432432
line['license_text_file'] = dje_license_dict[lic_name][0] + '.LICENSE'
433433
else:
434-
self.warnings.append(Warn(VALUE, 'dje_license', '',
435-
"Missing 'dje_license' for " + line['about_file']))
434+
self.warnings.append(Warn(VALUE, 'dje_license_key', '',
435+
"Missing 'dje_license_key' for " + line['about_file']))
436436
return license_output_list
437437

438438
def pre_process_and_dje_license_dict(self, input_list, api_url, api_username, api_key):
@@ -441,14 +441,14 @@ def pre_process_and_dje_license_dict(self, input_list, api_url, api_username, ap
441441
license_dict = {}
442442
for line in input_list:
443443
try:
444-
if line['dje_license']:
445-
if '\n' in line['dje_license']:
444+
if line['dje_license_key']:
445+
if '\n' in line['dje_license_key']:
446446
line['dje_license_name'] = ""
447-
self.errors.append(Error(VALUE, 'dje_license',
448-
line['dje_license'],
447+
self.errors.append(Error(VALUE, 'dje_license_key',
448+
line['dje_license_key'],
449449
"No multiple licenses or newline character are accepted."))
450450
continue
451-
lic = line['dje_license']
451+
lic = line['dje_license_key']
452452
if not lic in license_dict:
453453
detail_list = []
454454
detail = self.get_license_details_from_api(api_url, api_username, api_key, lic)
@@ -464,8 +464,8 @@ def pre_process_and_dje_license_dict(self, input_list, api_url, api_username, ap
464464
line['dje_license_name'] = license_dict[lic]
465465
line['dje_license_url'] = dje_lic_urn + lic
466466
except Exception:
467-
err = Warn(VALUE, 'dje_license', '',
468-
'Missing "dje_license" for ' + line['about_file'])
467+
err = Warn(VALUE, 'dje_license_key', '',
468+
'Missing "dje_license_key" for ' + line['about_file'])
469469
self.warnings.append(err)
470470
return key_text_dict
471471

@@ -823,7 +823,6 @@ def main(parser, options, args):
823823
gen.copy_files(output_path, license_list)
824824

825825
if license_text_path:
826-
print(normpath(license_text_path))
827826
if not isdir(license_text_path):
828827
print("The '--license_text_location' <license_path> "
829828
"must be a directory.")
@@ -844,11 +843,11 @@ def main(parser, options, args):
844843
sys.exit(errno.EINVAL)
845844
for line in input_list:
846845
try:
847-
if line['dje_license']:
846+
if line['dje_license_key']:
848847
break
849848
except Exception as e:
850849
print(repr(e))
851-
print("The input does not have the 'dje_license' "
850+
print("The input does not have the 'dje_license_key' "
852851
"key which is required.")
853852
sys.exit(errno.EINVAL)
854853

about_code_tool/tests/test_about.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ def test_header_row_in_csv_output(self):
113113
'notice_file,notice_url,license_text_file,license_url,license_spdx,'
114114
'redistribute,attribute,track_changes,vcs_tool,vcs_repository,'
115115
'vcs_path,vcs_tag,vcs_branch,vcs_revision,checksum_sha1,checksum_md5,'
116-
'checksum_sha256,dje_component,dje_license,dje_organization,'
116+
'checksum_sha256,dje_component,dje_license_key,dje_organization,'
117117
'dje_license_name,scm_branch,scm_repository,signature_gpg_file,'
118-
'redistribute_sources,about_format,usage,'
119-
'license_text,notice,' # These two are not supported and thus treat as custom keys
120-
'scm_path,scm_tool,scm_rev,scm_tag,organization,'
118+
'redistribute_sources,dje_license,about_format,usage,'
119+
'license_text,notice,scm_path,scm_tool,scm_rev,scm_tag,organization,'
121120
'warnings,errors')
122121

123122
test_file = 'about_code_tool/tests/testdata/basic'
@@ -690,7 +689,8 @@ def test_get_custom_field_keys(self):
690689
about_file = about.AboutFile(join(TESTDATA_DIR, 'basic/basic.about'))
691690
result = about_file.get_custom_field_keys()
692691
expected = ['scm_branch', 'scm_repository', 'signature_gpg_file',
693-
'redistribute_sources', 'about_format', 'usage',
692+
'redistribute_sources', 'dje_license',
693+
'about_format', 'usage',
694694
# These two keys are removed from the spec and therefore
695695
# become a custom keys
696696
'license_text', 'notice',

about_code_tool/tests/test_genabout.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def test_get_dje_license_list_gen_license_with_dje_license_key_empty_license_tex
361361
'version': '0.8.1',
362362
'about_resource': '.',
363363
'name': 'ABOUT tool',
364-
'dje_license': 'apache-2.0',
364+
'dje_license_key': 'apache-2.0',
365365
'dje_license_name': 'Apache License 2.0',
366366
'license_text_file': ''}]
367367
gen_license = True
@@ -390,7 +390,7 @@ def test_get_dje_license_list_gen_license_with_empty_dje_license_key_empty_licen
390390
'about_resource': '.',
391391
'name': 'ABOUT tool',
392392
'license_text_file': '',
393-
'dje_license': ''}]
393+
'dje_license_key': ''}]
394394
gen_license = True
395395
dje_license_dict = {'Apache License 2.0': [u'apache-2.0',
396396
'test context']}
@@ -413,7 +413,7 @@ def test_get_dje_license_list_gen_license_with_dje_license_key_no_license_text_f
413413
'about_resource': '.',
414414
'name': 'ABOUT tool',
415415
'dje_license_name': 'Apache License 2.0',
416-
'dje_license': 'Apache License 2.0'}]
416+
'dje_license_key': 'apache-2.0'}]
417417

418418
expected = [('/', 'Apache License 2.0')]
419419
gen_license = True

0 commit comments

Comments
 (0)