Skip to content

Commit 580ac3e

Browse files
committed
Fixed #150 - Add error handling code to avoid writing empty value to the
attribution file
1 parent aca3742 commit 580ac3e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

about_code_tool/genattrib.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,15 @@ def main(parser, options, args):
218218
outlist = update_path_to_about(sublist)
219219

220220
attrib_str = collector.generate_attribution(template_path=template_location, limit_to=outlist)
221-
with open(output_path, "w") as f:
222-
f.write(attrib_str)
223221
errors = collector.get_genattrib_errors()
224222

223+
if attrib_str:
224+
try:
225+
with open(output_path, "w") as f:
226+
f.write(attrib_str)
227+
except:
228+
print("Problem occurs. Attribution is not generated.")
229+
225230
# Clear the log file
226231
with open(join(dirname(output_path), LOG_FILENAME), 'w'):
227232
pass

0 commit comments

Comments
 (0)