Skip to content

Commit fbe7604

Browse files
committed
Format python files witch black
1 parent fb2500b commit fbe7604

File tree

4 files changed

+49
-32
lines changed

4 files changed

+49
-32
lines changed

bin/mk-compiler-explorer.py

+22-14
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,66 @@
88
import sys
99

1010
head_re = re.compile("include/(?P<name>.*)\.hpp")
11+
12+
1113
def clean_name(file):
1214
match = head_re.match(file)
1315
return match.group("name")
1416

17+
1518
top = []
16-
for toplevel in glob.glob('include/?eman/*/*.hpp'):
19+
for toplevel in glob.glob("include/?eman/*/*.hpp"):
1720
top.append(clean_name(toplevel))
1821

1922
all = top.copy()
20-
for detail in glob.glob('include/?eman/*/?etail/*.hpp'):
23+
for detail in glob.glob("include/?eman/*/?etail/*.hpp"):
2124
all.append(clean_name(detail))
2225

2326
headers = {}
2427
beman_re = re.compile('#include ["<](?P<name>[bB]eman/.*)\.hpp[">]')
2528
other_re = re.compile('#include ["<](?P<name>.*)[">]')
2629

30+
2731
def get_dependencies(component):
2832
deps = []
2933
with open("include/" + component + ".hpp") as file:
3034
for line in file.readlines():
3135
if beman_re.match(line):
3236
deps.append(beman_re.match(line).group("name"))
33-
elif (other_re.match(line)):
37+
elif other_re.match(line):
3438
header = other_re.match(line).group("name")
3539
if header not in headers:
3640
headers[header] = 1
3741

3842
return deps
3943

44+
4045
dependencies = {}
4146

4247
for component in all:
4348
dependencies[component] = get_dependencies(component)
4449

4550
if len(sys.argv) != 2:
46-
print(f'usage: {sys.argv[0]} <target-dir>')
51+
print(f"usage: {sys.argv[0]} <target-dir>")
4752
sys.exit(1)
4853

4954
dir = sys.argv[1]
5055

5156
project_re = re.compile("(?P<project>(?P<beman>[bB]eman)/.*)/")
5257
define_re = re.compile("#define")
5358

59+
5460
def write_header(to, header):
55-
with open(f'include/{header}.hpp') as file:
61+
with open(f"include/{header}.hpp") as file:
5662
for line in file.readlines():
5763
if not beman_re.match(line) and not other_re.match(line):
5864
to.write(line)
5965

66+
6067
def build_header(file, to, header):
6168
includes = list(headers.keys())
6269
for include in includes:
63-
to.write(f'#include <{include}>\n')
70+
to.write(f"#include <{include}>\n")
6471

6572
deps = {}
6673
todo = dependencies[header].copy()
@@ -70,7 +77,7 @@ def build_header(file, to, header):
7077
for new in dependencies[todo[0]]:
7178
todo.append(new)
7279
todo = todo[1:]
73-
80+
7481
while 0 < len(deps):
7582
empty = [item for item in deps.keys() if 0 == len(deps[item])]
7683
for e in empty:
@@ -79,22 +86,23 @@ def build_header(file, to, header):
7986
for d in deps.keys():
8087
deps[d] = [item for item in deps[d] if e != item]
8188

89+
8290
for header in top:
8391
beman = project_re.match(header).group("beman")
84-
if not os.path.exists(f'{dir}/{beman}'):
85-
os.mkdir(f'{dir}/{beman}')
92+
if not os.path.exists(f"{dir}/{beman}"):
93+
os.mkdir(f"{dir}/{beman}")
8694
project = project_re.match(header).group("project")
87-
if not os.path.exists(f'{dir}/{project}'):
88-
os.mkdir(f'{dir}/{project}')
95+
if not os.path.exists(f"{dir}/{project}"):
96+
os.mkdir(f"{dir}/{project}")
8997

9098
prolog_done = False
91-
with open(f'include/{header}.hpp') as file:
92-
with open(f'{dir}/{header}.hpp', 'w') as to:
99+
with open(f"include/{header}.hpp") as file:
100+
with open(f"{dir}/{header}.hpp", "w") as to:
93101
for line in file.readlines():
94102
if not beman_re.match(line) and not other_re.match(line):
95103
to.write(line)
96104
if not prolog_done and define_re.match(line):
97105
prolog_done = True
98106
to.write("\n")
99107
build_header(file, to, header)
100-
to.write("\n")
108+
to.write("\n")

bin/mk-deps.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55

66
deps = {}
77

8-
done_re = re.compile('^(?P<state>.) (?P<name>.*)')
8+
done_re = re.compile("^(?P<state>.) (?P<name>.*)")
99
with open("deps") as file:
1010
for line in file.readlines():
1111
match = done_re.match(line)
1212
if match:
1313
deps[match.group("name")] = match.group("state")
1414

15-
result = subprocess.run(["/usr/bin/tsort", "docs/dependency.txt"], capture_output=True, encoding="utf-8")
15+
result = subprocess.run(
16+
["/usr/bin/tsort", "docs/dependency.txt"], capture_output=True, encoding="utf-8"
17+
)
1618
for line in result.stdout.split("\n"):
1719
if line != "":
18-
print(f'{deps[line] if line in deps else "-"} {line}')
20+
print(f'{deps[line] if line in deps else "-"} {line}')

bin/mk-todo.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import re
77
import urllib.request
88

9-
#-dk:TODO get from http://wg21.link/
9+
# -dk:TODO get from http://wg21.link/
1010
url = "https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html"
1111

1212
with urllib.request.urlopen(url) as f:
13-
html = f.read().decode('utf-8')
13+
html = f.read().decode("utf-8")
1414

1515
json = json.loads(open("docs/TODO.json").read())
1616

@@ -19,7 +19,7 @@
1919
list.append("exec.awaitables")
2020

2121
fail = "&#x2705;" # "&#9744;"
22-
ok = "&#x1F534;" # "&#9745;"
22+
ok = "&#x1F534;" # "&#9745;"
2323

2424
with open("docs/TODO.md", "w") as todo:
2525
print(f"# ToDo ", file=todo)
@@ -31,6 +31,9 @@
3131
if not node.get("removed", False):
3232
code = fail if node.get("code", False) else ok
3333
test = fail if node.get("test", False) else ok
34-
doc = fail if node.get("doc", False) else ok
34+
doc = fail if node.get("doc", False) else ok
3535
comment = node.get("comment", "")
36-
print(f"| [[{name}]({url}#{name})] | {code} | {test} | {doc} | {comment} |", file=todo)
36+
print(
37+
f"| [[{name}]({url}#{name})] | {code} | {test} | {doc} | {comment} |",
38+
file=todo,
39+
)

bin/update-cmake-headers.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,44 @@
88
import sys
99

1010
head_re = re.compile("include/(?P<name>.*)\.hpp")
11+
12+
1113
def clean_name(file):
1214
match = head_re.match(file)
1315
return match.group("name")
1416

17+
1518
def get_headers(dir):
1619
result = []
17-
for header in glob.glob(dir + '/*.hpp'):
20+
for header in glob.glob(dir + "/*.hpp"):
1821
result.append(clean_name(header))
1922
result.sort()
2023
return result
2124

25+
2226
sections = {
23-
'public': get_headers('include/beman/*'),
24-
'detail': get_headers('include/beman/*/detail'),
27+
"public": get_headers("include/beman/*"),
28+
"detail": get_headers("include/beman/*/detail"),
2529
}
2630

2731
file_set_re = re.compile(" *FILE_SET.*")
28-
section_re = re.compile(" *\${TARGET_LIBRARY}_(?P<section>.*)_headers$")
29-
header_re = re.compile(" *\${PROJECT_SOURCE_DIR}/include/beman/.*/.*\.hpp")
32+
section_re = re.compile(" *\${TARGET_LIBRARY}_(?P<section>.*)_headers$")
33+
header_re = re.compile(" *\${PROJECT_SOURCE_DIR}/include/beman/.*/.*\.hpp")
3034

3135
if len(sys.argv) != 2:
32-
print(f'usage: {sys.argv[0]} <path>/CMakeLists.txt')
36+
print(f"usage: {sys.argv[0]} <path>/CMakeLists.txt")
3337
sys.exit(1)
3438

3539
cmake = sys.argv[1]
36-
print(f'updating {cmake}')
40+
print(f"updating {cmake}")
3741

3842
section = ""
3943
section_done = False
4044

41-
with open(cmake, 'r') as input:
45+
with open(cmake, "r") as input:
4246
lines = input.readlines()
4347

44-
with open(f'{cmake}', 'w') as output:
48+
with open(f"{cmake}", "w") as output:
4549
for line in lines:
4650
if None != file_set_re.match(line):
4751
section = ""
@@ -54,7 +58,7 @@ def get_headers(dir):
5458
section_done = True
5559
project = "${PROJECT_SOURCE_DIR}"
5660
for header in sections[section]:
57-
output.write(f' {project}/include/{header}.hpp\n')
61+
output.write(f" {project}/include/{header}.hpp\n")
5862
else:
5963
output.write(line)
6064
pass

0 commit comments

Comments
 (0)