Skip to content

Commit 97cfd2a

Browse files
committed
Let black and ruff reformat and fix projcode. Minor style adjustments and
comment updates.
1 parent 2ab0123 commit 97cfd2a

File tree

2 files changed

+73
-61
lines changed

2 files changed

+73
-61
lines changed

bin/addheader.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@
9898

9999

100100
def check_header(path, var_dict, preamble_lines=100):
101-
"""Check if path already has a credible license header. Only looks inside
102-
the first preamble_size bytes of the file.
101+
"""Check if path has a credible license header and otherwise adds one.
102+
103+
Only looks inside the first preamble_lines of the file and if it doesn't
104+
find an existing license header there it adds a standard header populated
105+
with project variables from var_dict.
103106
"""
104107
module_preamble = "\n".join(read_head_lines(path, preamble_lines, None))
105108
return (

mig/shared/projcode.py

+68-59
Original file line numberDiff line numberDiff line change
@@ -25,93 +25,102 @@
2525

2626
from mig.shared.defaults import keyword_all
2727

28-
# TODO: phase out lowercase names once all scripts switched to get_code_files
28+
# TODO: phase out lowercase names once all scripts switched to list_code_files
2929

3030
# Top dir with all code
31-
CODE_ROOT = code_root = 'mig'
31+
code_root = "mig"
32+
CODE_ROOT = code_root
3233

3334
# Ignore backup and dot files in wild card match
34-
PLAIN = '[a-zA-Z0-9]*.py'
35+
PLAIN = "[a-zA-Z0-9]*.py"
3536
py_code_files = [
3637
# a few scripts are in parent dir of code_root
37-
'../%s' % PLAIN,
38-
'../bin/%s' % PLAIN,
39-
'../sbin/%s' % PLAIN,
40-
'%s' % PLAIN,
41-
'lib/%s' % PLAIN,
42-
'cgi-bin/%s' % PLAIN,
43-
'cgi-sid/%s' % PLAIN,
44-
'install/%s' % PLAIN,
45-
'migfs-fuse/%s' % PLAIN,
46-
'resource/bin/%s' % PLAIN,
47-
'resource/image-scripts/%s' % PLAIN,
48-
'resource/keepalive-scripts/%s' % PLAIN,
49-
'server/%s' % PLAIN,
50-
'shared/%s' % PLAIN,
51-
'shared/functionality/%s' % PLAIN,
52-
'shared/distos/%s' % PLAIN,
53-
'shared/gdp/%s' % PLAIN,
54-
'shared/griddaemons/%s' % PLAIN,
55-
'simulation/%s' % PLAIN,
56-
'user/%s' % PLAIN,
57-
'vm-proxy/%s' % PLAIN,
58-
'webserver/%s' % PLAIN,
59-
'wsgi-bin/%s' % PLAIN,
38+
"../%s" % PLAIN,
39+
"../bin/%s" % PLAIN,
40+
"../sbin/%s" % PLAIN,
41+
"%s" % PLAIN,
42+
"lib/%s" % PLAIN,
43+
"cgi-bin/%s" % PLAIN,
44+
"cgi-sid/%s" % PLAIN,
45+
"install/%s" % PLAIN,
46+
"migfs-fuse/%s" % PLAIN,
47+
"resource/bin/%s" % PLAIN,
48+
"resource/image-scripts/%s" % PLAIN,
49+
"resource/keepalive-scripts/%s" % PLAIN,
50+
"server/%s" % PLAIN,
51+
"shared/%s" % PLAIN,
52+
"shared/functionality/%s" % PLAIN,
53+
"shared/distos/%s" % PLAIN,
54+
"shared/gdp/%s" % PLAIN,
55+
"shared/griddaemons/%s" % PLAIN,
56+
"simulation/%s" % PLAIN,
57+
"user/%s" % PLAIN,
58+
"vm-proxy/%s" % PLAIN,
59+
"webserver/%s" % PLAIN,
60+
"wsgi-bin/%s" % PLAIN,
61+
]
62+
py_code_files += [
63+
"cgi-sid/%s" % name for name in ["requestnewjob", "putrespgid"]
6064
]
61-
py_code_files += ['cgi-sid/%s' % name for name in ['requestnewjob',
62-
'putrespgid']]
6365

64-
py_code_files += ['cgi-bin/%s' % name for name in [
65-
'listdir',
66-
'mkdir',
67-
'put',
68-
'remove',
69-
'rename',
70-
'rmdir',
71-
'stat',
72-
'walk',
73-
'getrespgid',
74-
]]
66+
py_code_files += [
67+
"cgi-bin/%s" % name
68+
for name in [
69+
"listdir",
70+
"mkdir",
71+
"put",
72+
"remove",
73+
"rename",
74+
"rmdir",
75+
"stat",
76+
"walk",
77+
"getrespgid",
78+
]
79+
]
7580
PY_CODE_FILES = py_code_files
7681

7782
sh_code_files = [
78-
'resource/frontend_script.sh',
79-
'resource/master_node_script.sh',
80-
'resource/leader_node_script.sh',
81-
'resource/dummy_node_script.sh',
83+
"resource/frontend_script.sh",
84+
"resource/master_node_script.sh",
85+
"resource/leader_node_script.sh",
86+
"resource/dummy_node_script.sh",
8287
]
8388
SH_CODE_FILES = sh_code_files
8489

8590
js_code_files = [
86-
'images/js/jquery.accountform.js',
87-
'images/js/jquery.ajaxhelpers.js',
88-
'images/js/jquery.confirm.js',
89-
'images/js/jquery.filemanager.js',
90-
'images/js/jquery.jobmanager.js',
91-
'images/js/jquery.migtools.js',
92-
'images/js/jquery.prettyprint.js',
93-
'images/js/preview-caman.js',
94-
'images/js/preview.js',
95-
'images/js/preview-paraview.js',
96-
'assets/js/shared/ui-dynamic.js',
97-
'assets/js/V3/ui-global.js',
98-
'assets/js/V3/ui-extra.js',
91+
"images/js/jquery.accountform.js",
92+
"images/js/jquery.ajaxhelpers.js",
93+
"images/js/jquery.confirm.js",
94+
"images/js/jquery.filemanager.js",
95+
"images/js/jquery.jobmanager.js",
96+
"images/js/jquery.migtools.js",
97+
"images/js/jquery.prettyprint.js",
98+
"images/js/preview-caman.js",
99+
"images/js/preview.js",
100+
"images/js/preview-paraview.js",
101+
"assets/js/shared/ui-dynamic.js",
102+
"assets/js/V3/ui-global.js",
103+
"assets/js/V3/ui-extra.js",
99104
]
100105
JS_CODE_FILES = js_code_files
101106

102107
code_files = py_code_files + sh_code_files + js_code_files
103108
CODE_FILES = code_files
104109

105110
PYTHON, SHELL, JAVASCRIPT = "PYTHON", "SHELL", "JAVASCRIPT"
106-
LANG_MAP = {keyword_all: CODE_FILES, PYTHON: PY_CODE_FILES,
107-
JAVASCRIPT: JS_CODE_FILES, SHELL: SH_CODE_FILES}
111+
LANG_MAP = {
112+
keyword_all: CODE_FILES,
113+
PYTHON: PY_CODE_FILES,
114+
JAVASCRIPT: JS_CODE_FILES,
115+
SHELL: SH_CODE_FILES,
116+
}
108117

109118

110119
def list_code_files(code_langs=[keyword_all]):
111120
"""Get list of all code files."""
112121
match = []
113122
for lang in code_langs:
114-
if not lang in LANG_MAP:
123+
if lang not in LANG_MAP:
115124
print("Warning: no such code lang: %s" % lang)
116125
else:
117126
match += LANG_MAP[lang]

0 commit comments

Comments
 (0)