Commit e3e58c69 authored by Ted Themistokleous's avatar Ted Themistokleous
Browse files

license_stamper: Update hasKeySequence() to limit lines searched

Since there's no point to check for a licence twice, just break after we find
the key_messag we're looking for otherwise break at some predetermined line
limit. Saves us from having to drudge through all of a file.

A license should be at the top of a file so anything more than 10 lines past
the beginning of the file (since we're also stamping .ipynb files) should be sufficient
parent f9c4988e
...@@ -63,8 +63,17 @@ def getipynb_markdownBlockAsList(): ...@@ -63,8 +63,17 @@ def getipynb_markdownBlockAsList():
def hasKeySequence(inputfile, key_message): def hasKeySequence(inputfile, key_message):
result = False result = False
if key_message in inputfile: line_cnt = 0
result = True line_limit = 10
for line in inputfile:
line_cnt = line_cnt + 1
if key_message in line:
result = True
break
if line_cnt >= line_limit:
break
return result return result
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment