From 5a8fb63ab0197e5fa1eb83ccb4d125eb1803337f Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Tue, 24 Nov 2020 22:44:42 +0100 Subject: [PATCH] normalize-usercode: comments --- devtools/code-tools/normalize-usercode.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devtools/code-tools/normalize-usercode.py b/devtools/code-tools/normalize-usercode.py index 3d9eaf9e55e..5cf36d0cdc7 100755 --- a/devtools/code-tools/normalize-usercode.py +++ b/devtools/code-tools/normalize-usercode.py @@ -20,12 +20,15 @@ def normalize_text(ti, fname): def normalize_file(fname, inplace): try: + # read file, normalize with open(fname, 'r') as f: ti = f.read() t = normalize_text(ti, fname) if t == ti: print(f'FILE {fname}: WAS OK') return + + # check invariance under second normalization t2 = normalize_text(t, fname) if t2 != t: with open("out1.py", 'w') as f: @@ -34,6 +37,7 @@ def normalize_file(fname, inplace): f.write(t2) exit(f'FILE {fname}: BUG - changes under second normalization, see files out1.py and out2.py') + # output if inplace: with open(fname, 'w') as f: f.write(t) -- GitLab