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

normalize-usercode: for the time being, replace only get_sample

parent 7dc9f09f
Branches
Tags
No related merge requests found
...@@ -36,7 +36,8 @@ def substitute_sample(ti, tc): ...@@ -36,7 +36,8 @@ def substitute_sample(ti, tc):
t = re.sub(pat, header + mn.group(3) + mi.group(6), ti) t = re.sub(pat, header + mn.group(3) + mi.group(6), ti)
t = re.sub(r'\nfrom bornagain import.+?', '\nfrom bornagain import deg, nm, nm2, kvector_t', t) t = re.sub(r'\nfrom bornagain import.+?',
'\nfrom bornagain import deg, nm, nm2, kvector_t', t)
return t return t
...@@ -61,17 +62,16 @@ def cycle_text(ti, fname): ...@@ -61,17 +62,16 @@ def cycle_text(ti, fname):
def normalize_text(ti, fname): def normalize_text(ti, fname):
tc = cycle_text(ti, fname) tc = cycle_text(ti, fname)
if verbose: if verbose:
print(f'.. cycled through BA, {len(ti.split())} -> {len(tc.split())} lines') print(
f'.. cycled through BA, {len(ti.split())} -> {len(tc.split())} lines'
)
tf = substitute_sample(ti, tc) tf = substitute_sample(ti, tc)
if verbose: if verbose:
print(f'.. normalized, {len(ti.split())} -> {len(tf.split())} lines') print(f'.. normalized, {len(ti.split())} -> {len(tf.split())} lines')
# YAPF formatting # YAPF formatting
tf = FormatCode( tf = FormatCode(tf,
tf, style_config='{based_on_style: pep8, column_limit: 80, '
style_config= 'no_spaces_around_selected_binary_operators: "*,/"}')[0]
'{based_on_style: pep8, column_limit: 85, '
'no_spaces_around_selected_binary_operators: "*,/"}'
)[0]
return tf return tf
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment