Skip to content

Commit 32f23f0

Browse files
committed
#90: Added common_license list so that a user can input a list of common
licenses which would be displayed at the end of the attribution file. Licenses not present in this list will be displayed inline with the component.
1 parent 2cff1ee commit 32f23f0

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

about_code_tool/about.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,7 @@ def generate_attribution(self, template_path='templates/default.html',
10971097
license_key = []
10981098
license_text = []
10991099
license_dict = {}
1100+
common_license = ['GPL 2.0','OpenSSL/SSLeay License', 'Apache 2.0', 'BSD-Modified']
11001101
for about_object in self:
11011102
about_relative_path = '/'+ about_object.location.partition(self.user_provided_path)[2]
11021103
if not limit_to or about_relative_path in limit_to:
@@ -1140,7 +1141,9 @@ def generate_attribution(self, template_path='templates/default.html',
11401141
return template.render(about_objects=validated_fields,
11411142
license_keys=license_key,
11421143
license_texts = license_text,
1143-
notice_texts=notice_text)
1144+
notice_texts=notice_text,
1145+
license_dicts=license_dict,
1146+
common_licenses=common_license)
11441147

11451148
def get_genattrib_errors(self):
11461149
return self.genattrib_errors

about_code_tool/templates/default.html

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ <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 }}.
55+
{% endif %}
5356
{% if about_object.copyright %}
5457
<pre>{{about_object.copyright}}</pre>
5558
{% endif %}
@@ -58,27 +61,37 @@ <h3 class="component-name">{{ about_object.name }}
5861
{% elif about_object.notice_file %}
5962
<pre class="component-notice">{{ notice_texts[loop.index0] }}</pre>
6063
{% endif %}
61-
{% if about_object.dje_license in license_keys %}
62-
<p>Full text of
63-
<a class="{{ about_object.dje_license }}" href="#component-license-{{ about_object.dje_license }}">
64-
{{ about_object.dje_license }}
65-
</a>
66-
is available at the end of this document.</p>
67-
{% elif about_object.license_text_file in license_keys %}
68-
<p>Full text of
69-
<a class="{{ about_object.license_text_file }}" href="#component-license-{{ about_object.license_text_file }}">
70-
{{ about_object.license_text_file }}
71-
</a>
72-
is available at the end of this document.</p>
64+
{% if about_object.dje_license in license_dicts.keys() %}
65+
{% if about_object.dje_license in common_licenses %}
66+
<p>Full text of
67+
<a class="{{ about_object.dje_license }}" href="#component-license-{{ about_object.dje_license }}">
68+
{{ about_object.dje_license}}
69+
</a>
70+
is available at the end of this document.</p>
71+
{% else %}
72+
<pre>{{ license_dicts[about_object.dje_license] }}</pre>
73+
{% endif %}
74+
{% elif about_object.license_text_file in license_dicts.keys() %}
75+
{% if about_object.license_text_file in common_licenses %}
76+
<p>Full text of
77+
<a class="{{ about_object.license_text_file }}" href="#component-license-{{ about_object.license_text_file }}">
78+
{{ about_object.license_text_file }}
79+
</a>
80+
is available at the end of this document.</p>
81+
{% else %}
82+
<pre>{{ license_dicts[about_object.license_text_file] }}</pre>
83+
{% endif %}
7384
{% endif %}
7485
</div>
7586
{% endfor %}
7687
<hr>
7788

7889
<h3>Licenses Used in This Product</h3>
7990
{% for index in range(license_keys | count) %}
80-
<h3 id="component-license-{{ license_keys[index] }}">{{ license_keys[index] }}</h3>
81-
<pre>{{ license_texts[index] }}</pre>
91+
{% if license_keys[index] in common_licenses %}
92+
<h3 id="component-license-{{ license_keys[index] }}">{{ license_keys[index] }}</h3>
93+
<pre>{{ license_texts[index] }}</pre>
94+
{% endif %}
8295
{% endfor %}
8396
<h3><a id="End">End</a></h3>
8497
</body>

0 commit comments

Comments
 (0)