Fix pylint issues

This commit is contained in:
hrkrshnn
2021-06-30 10:38:37 +02:00
parent f5d659da0c
commit 0ef7d27dbd
7 changed files with 31 additions and 18 deletions
+10 -4
View File
@@ -13,7 +13,8 @@ import hashlib
from os.path import join, isfile, split
def extract_test_cases(path):
lines = open(path, encoding="utf8", errors='ignore', mode='r', newline='').read().splitlines()
with open(path, encoding="utf8", errors='ignore', mode='r', newline='') as file:
lines = file.read().splitlines()
inside = False
delimiter = ''
@@ -45,7 +46,10 @@ def extract_docs_cases(path):
tests = []
# Collect all snippets of indented blocks
for l in open(path, mode='r', errors='ignore', encoding='utf8', newline='').read().splitlines():
with open(path, mode='r', errors='ignore', encoding='utf8', newline='') as f:
lines = f.read().splitlines()
for l in lines:
if l != '':
if not insideBlock and l.startswith(' '):
# start new test
@@ -87,14 +91,16 @@ def write_cases(f, tests):
# so before checking remove 4 spaces from each line.
remainder = re.sub(r'^ {4}', '', test, 0, re.MULTILINE)
sol_filename = 'test_%s_%s.sol' % (hashlib.sha256(test.encode("utf-8")).hexdigest(), cleaned_filename)
open(sol_filename, mode='w', encoding='utf8', newline='').write(remainder)
with open(sol_filename, mode='w', encoding='utf8', newline='') as fi:
fi.write(remainder)
def extract_and_write(f, path):
if docs:
cases = extract_docs_cases(path)
else:
if f.endswith('.sol'):
cases = [open(path, mode='r', encoding='utf8', newline='').read()]
with open(path, mode='r', encoding='utf8', newline='') as _f:
cases = [_f.read()]
else:
cases = extract_test_cases(path)
write_cases(f, cases)