Skip to content

Commit e2f03be

Browse files
ZedThreegithub-actions[bot]
authored andcommitted
Apply black changes
1 parent 79d6ed0 commit e2f03be

File tree

43 files changed

+41
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+41
-124
lines changed

bin/bout-add-mod-path

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ def create_mod(modulepath, name, top, build):
104104
else:
105105
prereq = ""
106106
with open(filename, "w") as f:
107-
f.write(
108-
f"""#%Module 1.0
107+
f.write(f"""#%Module 1.0
109108
#
110109
# BOUT++ module for use with 'environment-modules' package
111110
# Created by bout-add-mod-path v0.9
@@ -119,17 +118,14 @@ setenv BOUT_TOP {top}
119118
prepend-path PATH {top}/bin
120119
prepend-path PYTHONPATH {top}/tools/pylib
121120
prepend-path IDL_PATH +{top}/tools/idllib:'<IDL_DEFAULT>'
122-
"""
123-
)
121+
""")
124122
if build != top:
125-
f.write(
126-
f"""#%Module 1.0
123+
f.write(f"""#%Module 1.0
127124
setenv BOUT_BUILD {build}
128125
prepend-path PATH {build}/bin
129126
prepend-path LD_LIBRARY_PATH {build}/lib
130127
prepend-path PYTHONPATH {build}/tools/pylib
131-
"""
132-
)
128+
""")
133129
print(f"created `{filename}`")
134130

135131

bin/bout-pylib-cmd-to-bin

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def createwrapper(mod, func_name, func, name):
126126
out += end
127127
f.write(out)
128128

129-
fprint(
130-
"""#!/usr/bin/env python3
129+
fprint("""#!/usr/bin/env python3
131130
# PYTHON_ARGCOMPLETE_OK
132131
133132
import argparse
@@ -136,8 +135,7 @@ try:
136135
except ImportError:
137136
argcomplete=None
138137
139-
"""
140-
)
138+
""")
141139
doc = True
142140
para = False
143141
ret = False
@@ -183,19 +181,16 @@ except ImportError:
183181
arg_help[curarg].append(esc(blas))
184182
# Print functions that are needed
185183
if "str_to_slice" in arg_type.values():
186-
fprint(
187-
"""
184+
fprint("""
188185
def str_to_slice(sstr):
189186
args=[]
190187
for s in sstr.split(','):
191188
args.append(int(s))
192189
print(args)
193190
return slice(*args)
194-
"""
195-
)
191+
""")
196192
if "str_to_bool" in arg_type.values():
197-
fprint(
198-
"""
193+
fprint("""
199194
def str_to_bool(sstr):
200195
low=sstr.lower()
201196
# no or false
@@ -206,8 +201,7 @@ def str_to_bool(sstr):
206201
return True
207202
else:
208203
raise ArgumentTypeError("Cannot parse %s to bool type"%sstr)
209-
"""
210-
)
204+
""")
211205
# Create the parser
212206
fprint("parser = argparse.ArgumentParser(%s)" % (esc(docs)))
213207
spec = inspect.signature(func)
@@ -247,24 +241,19 @@ def str_to_bool(sstr):
247241
pre = "\n "
248242
fprint(")")
249243

250-
fprint(
251-
"""
244+
fprint("""
252245
if argcomplete:
253246
argcomplete.autocomplete(parser)
254247
255-
# late import for faster auto-complete"""
256-
)
248+
# late import for faster auto-complete""")
257249
fprint("from %s import %s" % (mod, func_name))
258-
fprint(
259-
"""
250+
fprint("""
260251
args = parser.parse_args()
261252
262253
# Call the function %s, using command line arguments
263254
%s(**args.__dict__)
264255
265-
"""
266-
% (func_name, func_name)
267-
)
256+
""" % (func_name, func_name))
268257
# alternative, but I think 0o755 is easier to read
269258
# import stat
270259
# os.chmod(filename,stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH)

bin/bout-v5-factory-upgrader.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import difflib
66
import re
77

8-
98
# Dictionary of factory methods that may need updating
109
factories = {
1110
"Interpolation": {
@@ -62,9 +61,7 @@ def find_factory_calls(factory, source):
6261
\s*=\s*
6362
{factory_name}::
6463
.*{create_method}.*
65-
""".format(
66-
**factory
67-
),
64+
""".format(**factory),
6865
source,
6966
re.VERBOSE,
7067
)
@@ -75,9 +72,7 @@ def find_type_pointers(factory, source):
7572
r"""
7673
\b{type_name}\s*\*\s* # Type name and pointer
7774
([\w_]+)\s*; # Variable name
78-
""".format(
79-
**factory
80-
),
75+
""".format(**factory),
8176
source,
8277
re.VERBOSE,
8378
)
@@ -107,9 +102,7 @@ def fix_declarations(factory, variables, source):
107102
(.*?)(class\s*)? # optional "class" keyword
108103
\b({type_name})\s*\*\s* # Type-pointer
109104
({variable_name})\s*; # Variable
110-
""".format(
111-
type_name=factory["type_name"], variable_name=variable
112-
),
105+
""".format(type_name=factory["type_name"], variable_name=variable),
113106
r"\1std::unique_ptr<\3> \4{nullptr};",
114107
source,
115108
flags=re.VERBOSE,
@@ -123,9 +116,7 @@ def fix_declarations(factory, variables, source):
123116
({variable_name})\s* # Variable
124117
=\s* # Assignment from factory
125118
({factory_name}::.*{create_method}.*);
126-
""".format(
127-
variable_name=variable, **factory
128-
),
119+
""".format(variable_name=variable, **factory),
129120
r"\1auto \4 = \5;",
130121
source,
131122
flags=re.VERBOSE,
@@ -139,9 +130,7 @@ def fix_declarations(factory, variables, source):
139130
({variable_name})\s* # Variable
140131
=\s* # Assignment
141132
(0|nullptr|NULL);
142-
""".format(
143-
variable_name=variable, **factory
144-
),
133+
""".format(variable_name=variable, **factory),
145134
r"\1std::unique_ptr<\2> \3{nullptr};",
146135
source,
147136
flags=re.VERBOSE,

bin/bout-v5-format-upgrader.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import difflib
66
import re
77

8-
98
format_replacements = {
109
"c": "c",
1110
"d": "d",

bin/bout-v5-header-upgrader.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import List
1010
from subprocess import run
1111

12-
1312
header_shim_sentinel = "// BOUT++ header shim"
1413

1514
header_warning = f"""\
@@ -122,8 +121,7 @@ def create_patch(filename, original, modified):
122121
if __name__ == "__main__":
123122
parser = argparse.ArgumentParser(
124123
formatter_class=argparse.RawDescriptionHelpFormatter,
125-
description=textwrap.dedent(
126-
"""\
124+
description=textwrap.dedent("""\
127125
Fix deprecated header locations for BOUT++ v4 -> v5
128126
129127
All BOUT++ headers are now under ``include/bout`` and
@@ -142,8 +140,7 @@ def create_patch(filename, original, modified):
142140
If you have staged changes, this tool will not work, so to
143141
avoid committing undesired or unrelated changes.
144142
145-
"""
146-
),
143+
"""),
147144
)
148145

149146
parser.add_argument(

bin/bout-v5-input-file-upgrader.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ def possibly_apply_patch(patch, options_file, quiet=False, force=False):
271271
if __name__ == "__main__":
272272
parser = argparse.ArgumentParser(
273273
formatter_class=argparse.RawDescriptionHelpFormatter,
274-
description=textwrap.dedent(
275-
"""\
274+
description=textwrap.dedent("""\
276275
Fix input files for BOUT++ v5+
277276
278277
Please note that this will only fix input options in sections with
@@ -300,8 +299,7 @@ def possibly_apply_patch(patch, options_file, quiet=False, force=False):
300299
301300
Files that change in this way will have the "canonicalisation" patch
302301
presented first. If you choose not to apply this patch, the "upgrade
303-
fixer" patch will still include it."""
304-
),
302+
fixer" patch will still include it."""),
305303
)
306304

307305
parser.add_argument("files", action="store", nargs="+", help="Input files")

bin/bout-v5-macro-upgrader.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ def create_patch(filename, original, modified):
342342
if __name__ == "__main__":
343343
parser = argparse.ArgumentParser(
344344
formatter_class=argparse.RawDescriptionHelpFormatter,
345-
description=textwrap.dedent(
346-
"""\
345+
description=textwrap.dedent("""\
347346
Fix macro defines for BOUT++ v4 -> v5
348347
349348
Please note that this is only slightly better than dumb text replacement. It
@@ -359,8 +358,7 @@ def create_patch(filename, original, modified):
359358
still replace them in strings or comments.
360359
361360
Please check the diff output carefully!
362-
"""
363-
),
361+
"""),
364362
)
365363

366364
parser.add_argument("files", action="store", nargs="+", help="Input files")

bin/bout-v5-physics-model-upgrader.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import textwrap
99
import warnings
1010

11-
1211
PHYSICS_MODEL_INCLUDE = '#include "bout/physicsmodel.hxx"'
1312

1413
PHYSICS_MODEL_SKELETON = """
@@ -213,13 +212,11 @@ def fix_bout_constrain(source, error_on_warning):
213212
"\n ".join(["{}:{}".format(i, source_lines[i]) for i in line_range])
214213
)
215214

216-
message = textwrap.dedent(
217-
"""\
215+
message = textwrap.dedent("""\
218216
Some uses of `bout_constrain` remain, but we could not automatically
219217
convert them to use `Solver::constraint`. Please fix them before
220218
continuing:
221-
"""
222-
)
219+
""")
223220
message += " " + "\n ".join(lines_context)
224221

225222
if error_on_warning:
@@ -389,8 +386,7 @@ def create_patch(filename, original, modified):
389386
if __name__ == "__main__":
390387
parser = argparse.ArgumentParser(
391388
formatter_class=argparse.RawDescriptionHelpFormatter,
392-
description=textwrap.dedent(
393-
"""\
389+
description=textwrap.dedent("""\
394390
Upgrade legacy physics models to use the PhysicsModel class
395391
396392
This will do the bare minimum required to compile, and
@@ -403,8 +399,7 @@ def create_patch(filename, original, modified):
403399
By default, this will use the file name stripped of file
404400
extensions as the name of the new class. Use '--name=<new
405401
name>' to give a different name.
406-
"""
407-
),
402+
"""),
408403
)
409404

410405
parser.add_argument("files", action="store", nargs="+", help="Files to fix")

bin/bout-v5-xzinterpolation-upgrader.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def fix_header_includes(old_header, new_header, source):
5454
(<|")
5555
({header}) # Header name
5656
(>|")
57-
""".format(
58-
header=old_header
59-
),
57+
""".format(header=old_header),
6058
r"\1\2{header}\4".format(header=new_header),
6159
source,
6260
flags=re.VERBOSE,
@@ -67,9 +65,7 @@ def fix_interpolations(old_interpolation, new_interpolation, source):
6765
return re.sub(
6866
r"""
6967
\b{}\b
70-
""".format(
71-
old_interpolation
72-
),
68+
""".format(old_interpolation),
7369
r"{}".format(new_interpolation),
7470
source,
7571
flags=re.VERBOSE,
@@ -120,9 +116,7 @@ def fix_factories(old_factory, new_factory, source):
120116
return re.sub(
121117
r"""
122118
\b{}\b
123-
""".format(
124-
old_factory
125-
),
119+
""".format(old_factory),
126120
r"{}".format(new_factory),
127121
source,
128122
flags=re.VERBOSE,

bin/update_version_number_in_files.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ def create_patch(filename, original, modified):
158158
if __name__ == "__main__":
159159
parser = argparse.ArgumentParser(
160160
formatter_class=argparse.RawDescriptionHelpFormatter,
161-
description=textwrap.dedent(
162-
"""\
161+
description=textwrap.dedent("""\
163162
Update the software version number to the specified version,
164163
to be given in the form major.minor.patch,
165164
e.g. 5.10.3
@@ -172,8 +171,7 @@ def create_patch(filename, original, modified):
172171
the 'minor' version number of the provided version will be incremented by 1,
173172
e.g. 5.10.3 -> 5.11.3
174173
175-
"""
176-
),
174+
"""),
177175
)
178176

179177
parser.add_argument(

0 commit comments

Comments
 (0)