Skip to content

Commit 1d934f2

Browse files
committed
Minor code changes and comments
1 parent 2956c00 commit 1d934f2

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

about_code_tool/about.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,13 +1224,12 @@ def write_to_csv(self, output_path):
12241224
row_data = about_object.get_row_data(relative_path, custom_keys)
12251225
csv_writer.writerow(row_data)
12261226

1227-
def generate_attribution(self, template_path, limit_to=None):
1227+
def generate_attribution(self, template_path=None, limit_to=None):
12281228
"""
12291229
Generate an attribution file from the current list of ABOUT objects.
12301230
The optional `limit_to` parameter allows to restrict the generated
12311231
attribution to a specific list of component names.
12321232
"""
1233-
12341233
try:
12351234
import jinja2 as j2
12361235
except ImportError:
@@ -1239,6 +1238,11 @@ def generate_attribution(self, template_path, limit_to=None):
12391238
'"configure"')
12401239
return
12411240

1241+
# For some reasons, if I set the template_path = "templates/default.html"
1242+
# in the parameter, the tempalte_path will become 'None' and cause error
1243+
if not template_path:
1244+
template_path = "templates/default.html"
1245+
12421246
# FIXME: the template dir should be outside the code tree
12431247
template_dir = os.path.dirname(template_path)
12441248
template_file_name = os.path.basename(template_path)
@@ -1249,7 +1253,6 @@ def generate_attribution(self, template_path, limit_to=None):
12491253
template = jinja_env.get_template(template_file_name)
12501254
except j2.TemplateNotFound:
12511255
return
1252-
12531256
limit_to = limit_to or []
12541257
limit_to = set(limit_to)
12551258

about_code_tool/genattrib.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ def main(parser, options, args):
133133
overwrite = options.overwrite
134134
verbosity = options.verbosity
135135
mapping_config = options.mapping
136-
template_location = options.template_location \
137-
if options.template_location else "templates/default.html"
136+
template_location = options.template_location
138137

139138
if options.version:
140139
print('ABOUT tool {0}\n{1}'.format(__version__, __copyright__))

about_code_tool/tests/test_about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ def test_remove_blank_lines_and_no_colon_fields(self):
605605
self.assertEqual(expected_warnings[i][0], w.code)
606606
self.assertEqual(expected_warnings[i][1], w.field_value)
607607

608-
def test_generate_attribution(self):
608+
def test_generate_attribution_with_custom_template(self):
609609
expected = (u'notice_text:'
610610
'version:2.4.3'
611611
'about_resource:httpd-2.4.3.tar.gz'

0 commit comments

Comments
 (0)