Skip to content

Commit 4f5de13

Browse files
committed
Introduce 'dje_license_name' and did some minor update
1 parent 1049108 commit 4f5de13

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

about_code_tool/about.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def repr_problem(obj):
156156
'dje_component',
157157
'dje_license',
158158
'dje_organization',
159+
'dje_license_name'
159160
)
160161

161162
OPTIONAL_FIELDS = BASIC_FIELDS + OWNERSHIP_FIELDS + LICENSE_FIELDS + \
@@ -935,7 +936,7 @@ def get_dje_license_name(self):
935936
Return the dje_license value if the dje_license field exists
936937
"""
937938
try:
938-
return self.parsed['dje_license']
939+
return self.parsed['dje_license_name']
939940
except Exception as e:
940941
pass
941942

@@ -1097,7 +1098,7 @@ def generate_attribution(self, template_path='templates/default.html',
10971098
license_key = []
10981099
license_text = []
10991100
license_dict = {}
1100-
common_license = ['GPL 2.0','OpenSSL/SSLeay License', 'Apache License 2.0', 'BSD-Modified']
1101+
common_license = ['GNU General Public License 2.0','OpenSSL/SSLeay License', 'Apache License 2.0', 'BSD-Modified']
11011102
for about_object in self:
11021103
about_relative_path = '/'+ about_object.location.partition(self.user_provided_path)[2]
11031104
if not limit_to or about_relative_path in limit_to:

about_code_tool/genabout.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
# The 'dje_license_key' will be removed and will use the 'dje_license' instead.
5959
SUPPORTED_FIELDS = about.OPTIONAL_FIELDS + about.MANDATORY_FIELDS + \
60-
('about_file', 'dje_license_key',)
60+
('about_file',)
6161

6262
Warn = namedtuple('Warn', 'field_name field_value message',)
6363
Error = namedtuple('Error', 'field_name field_value message',)
@@ -247,7 +247,7 @@ def request_license_data(self, url, username, api_key, license_key):
247247
self.extract_dje_license_error = True
248248
self.errors.append(Error('username/key', username + '/' + api_key, error_msg))
249249
else:
250-
self.errors.append(Error('dje_license_key', license_key, "Invalid 'dje_license_key'"))
250+
self.errors.append(Error('dje_license', license_key, "Invalid 'dje_license_key'"))
251251
return {}
252252
except urllib2.URLError:
253253
if about.check_network_connection():
@@ -321,28 +321,28 @@ def get_dje_license_list(self, gen_location, input_list, gen_license):
321321
self.errors.append(Error('license_text_file', license_file, "The 'license_text_file' does not exist."))
322322
else:
323323
if gen_license:
324-
if line['dje_license_key']:
324+
if line['dje_license']:
325325
license_output_list.append(self.gen_license_list(line))
326326
else:
327-
self.warnings.append(Warn('dje_license_key', '',
328-
"Missing 'dje_license_key' for " + line['about_file']))
327+
self.warnings.append(Warn('dje_license', '',
328+
"Missing 'dje_license' for " + line['about_file']))
329329
# This except condition will force the tool to create the
330330
# 'license_text_file' key column from the self.gen_license_list(line)
331331
except Exception as e:
332332
if gen_license:
333-
if line['dje_license_key']:
333+
if line['dje_license']:
334334
license_output_list.append(self.gen_license_list(line))
335335
else:
336-
self.warnings.append(Warn('dje_license_key', '',
337-
"Missing 'dje_license_key' for " + line['about_file']))
336+
self.warnings.append(Warn('dje_license', '',
337+
"Missing 'dje_license' for " + line['about_file']))
338338
return license_output_list
339339

340340
def pre_generation(self, gen_location, input_list, action_num, all_in_one, api_url, api_username, api_key):
341341
output_list = []
342342
for line in input_list:
343343
try:
344-
if api_url and line['dje_license_key']:
345-
line['dje_license'] = self.get_license_name_from_api(api_url, api_username, api_key, line['dje_license_key'])
344+
if api_url and line['dje_license']:
345+
line['dje_license_name'] = self.get_license_name_from_api(api_url, api_username, api_key, line['dje_license'])
346346
except Exception as e:
347347
pass
348348
component_list = []
@@ -387,7 +387,7 @@ def pre_generation(self, gen_location, input_list, action_num, all_in_one, api_u
387387

388388
@staticmethod
389389
def gen_license_list(line):
390-
dje_key = line['dje_license_key']
390+
dje_key = line['dje_license']
391391
file_location = line['about_file']
392392
if file_location.endswith('/'):
393393
file_location = file_location.rpartition('/')[0]
@@ -651,11 +651,11 @@ def main(parser, options, args):
651651
sys.exit(errno.EINVAL)
652652
for line in input_list:
653653
try:
654-
if line['dje_license_key']:
654+
if line['dje_license']:
655655
break
656656
except Exception as e:
657657
print(repr(e))
658-
print("The input does not have the 'dje_license_key' key which is required.")
658+
print("The input does not have the 'dje_license' key which is required.")
659659
sys.exit(errno.EINVAL)
660660

661661
dje_license_list = gen.get_dje_license_list(output_path, input_list, gen_license)

about_code_tool/templates/default.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ <h1>OPEN SOURCE SOFTWARE INFORMATION</h1>
5050
<h3 class="component-name">{{ about_object.name }}
5151
{% if about_object.version %}{{ about_object.version }}{% endif %}
5252
</h3>
53-
{% if about_object.dje_license in license_dicts.keys() %}
54-
<p>This component is licensed under {{about_object.dje_license }}.
53+
{% if about_object.dje_license_name in license_dicts.keys() %}
54+
<p>This component is licensed under {{about_object.dje_license_name }}.
5555
{% endif %}
5656
{% if about_object.copyright %}
5757
<pre>{{about_object.copyright}}</pre>
@@ -62,20 +62,20 @@ <h3 class="component-name">{{ about_object.name }}
6262
<pre class="component-notice">{{ notice_texts[loop.index0] }}</pre>
6363
{% endif %}
6464

65-
{% if about_object.dje_license in license_dicts.keys() %}
66-
{% if about_object.dje_license in common_licenses %}
65+
{% if about_object.dje_license_name in license_dicts.keys() %}
66+
{% if about_object.dje_license_name in common_licenses %}
6767
<p>Full text of
68-
<a class="{{ about_object.dje_license }}" href="#component-license-{{ about_object.dje_license }}">
69-
{{ about_object.dje_license }}
68+
<a class="{{ about_object.dje_license_name }}" href="#component-license-{{ about_object.dje_license_name }}">
69+
{{ about_object.dje_license_name }}
7070
</a>
7171
is available at the end of this document.</p>
7272
{% else %}
73-
<pre>{{ license_dicts[about_object.dje_license] }}</pre>
73+
<pre>{{ license_dicts[about_object.dje_license_name] }}</pre>
7474
{% endif %}
7575
{% elif about_object.license_text_file in license_dicts.keys() %}
76-
{% if about_object.dje_license in common_licenses %}
76+
{% if about_object.dje_license_name in common_licenses %}
7777
<p>
78-
This component is licensed under {{ about_object.dje_license }}.
78+
This component is licensed under {{ about_object.dje_license_name }}.
7979
</p>
8080
<p>Full text of
8181
<a class="{{ about_object.license_text_file }}" href="#component-license-{{ about_object.license_text_file }}">

0 commit comments

Comments
 (0)