89a68ecaaf009a541f9304f8483f73d5954e6540
1 from pathlib
import Path
7 SAFE_PATH
= re
.compile(r
"^[a-zA-Z0-9_./]*$")
10 # don't pick up any paths that need escaping nor any sby workdirs
11 if not SAFE_PATH
.match(str(path
)) or (path
/ "config.sby").exists():
14 checked_dirs
.append(path
)
15 for entry
in path
.glob("*.sby"):
17 if not SAFE_PATH
.match(filename
):
19 if not re
.match(r
"^[a-zA-Z0-9_./]*$", filename
):
20 print(f
"skipping {filename!r}, use only [a-zA-Z0-9_./] in filenames")
23 for entry
in path
.glob("*"):
29 collect(Path("../docs/examples"))
31 out_file
= Path("make/rules/collect.mk")
32 out_file
.parent
.mkdir(exist_ok
=True)
34 with out_file
.open("w") as output
:
37 for checked_dir
in checked_dirs
:
38 print(f
"{out_file}: {checked_dir}", file=output
)
41 print(f
"make/rules/test/{test}.mk: {test}", file=output
)
42 for ext
in [".sh", ".py"]:
43 script_file
= test
.parent
/ (test
.stem
+ ext
)
44 if script_file
.exists():
45 print(f
"make/rules/test/{test}.mk: {script_file}", file=output
)
46 print(f
"make/rules/test/{test}.mk: make/test_rules.py", file=output
)
48 print(f
"-include make/rules/test/{test}.mk", file=output
)