Skip to content

Commit fe44515

Browse files
committed
Fixed #77 to get the license from 'license_text_file' if component doesn't have 'dje_license'
1 parent 1f7f01a commit fe44515

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

about_code_tool/about.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,17 @@ def dje_license(self):
940940

941941
return "" # Returns empty string if the dje_license key does not exist
942942

943+
def get_license_text_file_name(self):
944+
"""
945+
Return the license_text_file name if the license_text_file field exists
946+
"""
947+
try:
948+
return self.parsed['license_text_file']
949+
except Exception as e:
950+
pass
951+
952+
return "" # Returns empty string if the license_text_file key does not exist
953+
943954
class AboutCollector(object):
944955
"""
945956
A collection of AboutFile instances.
@@ -1086,10 +1097,16 @@ def generate_attribution(self, template_path='templates/default.html',
10861097
if not limit_to or about_object.about_resource_path in limit_to:
10871098
validated_fields.append(about_object.validated_fields)
10881099
notice_text.append(about_object.notice_text())
1089-
if not about_object.dje_license() in unique_license \
1090-
and not about_object.dje_license() == None:
1091-
unique_license.append(about_object.dje_license())
1092-
license_text.append(about_object.license_text())
1100+
if about_object.dje_license():
1101+
if not about_object.dje_license() in unique_license \
1102+
and not about_object.dje_license() == None:
1103+
unique_license.append(about_object.dje_license())
1104+
license_text.append(about_object.license_text())
1105+
elif about_object.get_license_text_file_name():
1106+
if not about_object.get_license_text_file_name() in unique_license \
1107+
and about_object.license_text():
1108+
unique_license.append(about_object.get_license_text_file_name())
1109+
license_text.append(about_object.license_text())
10931110

10941111
return template.render(about_objects=validated_fields,
10951112
license_texts=license_text,

about_code_tool/templates/default.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,18 @@ <h3 class="component-name">{{ about_object.name }}{% if about_object.version %}
5353
{% elif about_object.notice_file %}
5454
<pre class="component-notice">{{ notice_texts[loop.index0] }}</pre>
5555
{% endif %}
56-
{% if about_object.dje_license %}
56+
{% if about_object.dje_license in unique_licenses %}
5757
<p>Full text of
5858
<a class="{{ about_object.dje_license }}" href="#component-license-{{ about_object.dje_license }}">
5959
{{ about_object.dje_license }}
6060
</a>
6161
is available at the end of this document.</p>
62+
{% elif about_object.license_text_file in unique_licenses %}
63+
<p>Full text of
64+
<a class="{{ about_object.license_text_file }}" href="#component-license-{{ about_object.license_text_file }}">
65+
{{ about_object.license_text_file }}
66+
</a>
67+
is available at the end of this document.</p>
6268
{% endif %}
6369
</div>
6470
{% endfor %}

0 commit comments

Comments
 (0)