1 from pathlib
import Path
7 SAFE_PATH
= re
.compile(r
"^[a-zA-Z0-9_./\\]*$")
11 # don't pick up any paths that need escaping nor any sby workdirs
12 if not SAFE_PATH
.match(str(path
)) or (path
/ "config.sby").exists():
15 checked_dirs
.append(path
)
16 for entry
in path
.glob("*.sby"):
18 if not SAFE_PATH
.match(filename
):
19 print(f
"skipping {filename!r}, use only [a-zA-Z0-9_./] in filenames")
22 for entry
in path
.glob("*"):
28 return "/".join(path
.parts
)
32 collect(Path("../docs/examples"))
34 out_file
= Path("make/rules/collect.mk")
35 out_file
.parent
.mkdir(exist_ok
=True)
37 with out_file
.open("w") as output
:
39 for checked_dir
in checked_dirs
:
40 print(f
"{out_file}: {checked_dir}", file=output
)
43 test_unix
= unix_path(test
)
44 print(f
"make/rules/test/{test_unix}.mk: {test_unix}", file=output
)
45 for ext
in [".sh", ".py"]:
46 script_file
= test
.parent
/ (test
.stem
+ ext
)
47 if script_file
.exists():
48 script_file_unix
= unix_path(script_file
)
49 print(f
"make/rules/test/{test_unix}.mk: {script_file_unix}", file=output
)
50 print(f
"make/rules/test/{test_unix}.mk: make/test_rules.py", file=output
)
52 test_unix
= unix_path(test
)
53 print(f
"-include make/rules/test/{test_unix}.mk", file=output
)