Fix print check regression

This commit is contained in:
Matt Guthaus
2018-10-15 13:23:31 -07:00
parent a165446fa7
commit e2cfd382b9
5 changed files with 19 additions and 12 deletions
+6 -3
View File
@@ -35,6 +35,8 @@ class code_format_test(openram_test):
continue
if re.search("openram.py$", code):
continue
if re.search("sram.py$", code):
continue
if re.search("gen_stimulus.py$", code):
continue
errors += check_print_output(code)
@@ -50,7 +52,7 @@ def setup_files(path):
for f in current_files:
files.append(os.path.join(dir, f))
nametest = re.compile("\.py$", re.IGNORECASE)
select_files = filter(nametest.search, files)
select_files = list(filter(nametest.search, files))
return select_files
@@ -100,16 +102,17 @@ def check_print_output(file_name):
"""Check if any files (except debug.py) call the _print_ function. We should
use the debug output with verbosity instead!"""
file = open(file_name, "r+b")
line = file.read()
line = file.read().decode('utf-8')
# skip comments with a hash
line = re.sub(r'#.*', '', line)
# skip doc string comments
line=re.sub(r'\"\"\"[^\"]*\"\"\"', '', line, flags=re.S|re.M)
count = len(re.findall("\s*print\s+", line))
count = len(re.findall("[^p]+print\(", line))
if count > 0:
debug.info(0, "\nFound " + str(count) +
" _print_ calls " + str(file_name))
file.close()
return(count)