Skip to content

Commit 95d9c6a

Browse files
committed
Fixed #63
Avoid grabbing and generating the same license more than once.
1 parent 8fac605 commit 95d9c6a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

about_code_tool/genabout.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,18 @@ def extract_dje_license(self, project_path, license_list, url, username, key):
245245
if '/' in gen_path:
246246
gen_path = gen_path.partition('/')[2]
247247
gen_license_path = join(project_path, gen_path, license_key) + '.LICENSE'
248-
context = self.get_license_text_from_api(url, username, key, license_key)
249-
if not context:
250-
self.errors.append(Error('dje_license_key', license_key,
251-
"Invalid 'dje_license_key'"))
252-
else:
253-
try:
254-
with open(gen_license_path, 'wb') as output:
255-
output.write(context.encode('utf8'))
256-
except Exception as e:
257-
self.errors.append(Error('Unknown', gen_license_path,
258-
"Something is wrong."))
248+
if not _exists(gen_license_path):
249+
context = self.get_license_text_from_api(url, username, key, license_key)
250+
if not context:
251+
self.errors.append(Error('dje_license_key', license_key,
252+
"Invalid 'dje_license_key'"))
253+
else:
254+
try:
255+
with open(gen_license_path, 'wb') as output:
256+
output.write(context.encode('utf8'))
257+
except Exception as e:
258+
self.errors.append(Error('Unknown', gen_license_path,
259+
"Something is wrong."))
259260

260261
@staticmethod
261262
def get_license_text_from_api(url, username, api_key, license_key):

0 commit comments

Comments
 (0)