Skip to content

Commit 848a058

Browse files
committed
Fixed #60
Fixed #61 Implement Warning and Error for blank and invalid 'dje_license_key'
1 parent 78b9ac8 commit 848a058

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

about_code_tool/genabout.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ def get_dje_license_key(self, input_list):
224224
dje_license_key_list.append(about_parent_dir)
225225
dje_license_key_list.append(dje_key)
226226
output_list.append(dje_license_key_list)
227+
else:
228+
self.warnings.append(Warn('dje_license_key', '',
229+
"No 'dje_license_key' for " + line['about_file']))
227230
except Exception as e:
228231
print(repr(e))
229232
print("The input does not have the 'dje_license_key' key which is required.")
@@ -241,8 +244,12 @@ def extract_dje_license(self, project_path, license_list, url, username, key):
241244
gen_path = gen_path.partition('/')[2]
242245
gen_license_path = join(project_path, gen_path, license_key) + '.LICENSE'
243246
context = self.get_license_text_from_api(url, username, key, license_key)
244-
with open(gen_license_path, 'wb') as output:
245-
output.write(context)
247+
if not context:
248+
self.errors.append(Error('dje_license_key', license_key,
249+
"Invalid 'dje_license_key'"))
250+
else:
251+
with open(gen_license_path, 'wb') as output:
252+
output.write(context)
246253

247254
@staticmethod
248255
def get_license_text_from_api(url, username, api_key, license_key):

0 commit comments

Comments
 (0)