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

normalize-usercode + yapf formatting

parent 9969b447
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ Export to normal form is done by BornAgain's ExportToPython function. ...@@ -6,6 +6,7 @@ Export to normal form is done by BornAgain's ExportToPython function.
""" """
import argparse, os, re import argparse, os, re
from yapf.yapflib.yapf_api import FormatCode
import bornagain as ba import bornagain as ba
def substitute_sample(ti, tc): def substitute_sample(ti, tc):
...@@ -55,6 +56,8 @@ def normalize_text(ti, fname): ...@@ -55,6 +56,8 @@ def normalize_text(ti, fname):
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
tf = FormatCode(tf, style_config='{based_on_style: pep8, column_limit: 85}')
return tf return tf
def normalize_file(fname, inplace): def normalize_file(fname, inplace):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment