Skip to content
Snippets Groups Projects
Commit 03048ea5 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

normalize-usercode: + verbose mode

parent 61376e1e
No related branches found
No related tags found
No related merge requests found
......@@ -25,12 +25,20 @@ def normalize_file(fname, inplace):
# read file, normalize
with open(fname, 'r') as f:
ti = f.read()
if verbose:
print(f'.. read {len(ti.split())} lines')
t = normalize_text(ti, fname)
if verbose:
print(f'.. normalized')
if t == ti:
if verbose:
print(f'.. nothing changed')
return 0
# check invariance under second normalization
t2 = normalize_text(t, fname)
if verbose:
print(f'.. re-normalized')
if t2 != t:
with open("out1.py", 'w') as f:
f.write(t)
......@@ -56,7 +64,9 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("input_files", nargs='+', type=str)
parser.add_argument("-i", "--in-place", action="store_true")
parser.add_argument("-v", "--verbose", action="store_true")
args = parser.parse_args()
verbose = args.verbose
count = [0, 0, 0]
for f in args.input_files:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment