8000 Set ignores if there are skips (#20) · cgb-algorithm/scripts@a708d83 · GitHub
[go: up one dir, main page]

Skip to content

Commit a708d83

Browse files
authored
Set ignores if there are skips (TheAlgorithms#20)
`ignore` was not getting set `if len(args) == 5`
1 parent 8c4dc10 commit a708d83

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

build_directory_md.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@
1919
)
2020
sys.exit()
2121

22-
ignore = []
23-
skip = []
24-
if len(sys.argv) == 4:
25-
ignore = sys.argv[3].split(",")
26-
if len(sys.argv) == 5:
27-
skip = sys.argv[4].split(",")
22+
ignore = sys.argv[3].split(",") if len(sys.argv) >= 4 else []
23+
skip = sys.argv[4].split(",") if len(sys.argv) == 5 else []
2824

2925
URL_BASE = f"https://github.com/TheAlgorithms/{sys.argv[0]}/blob/HEAD"
3026

@@ -33,17 +29,14 @@ def good_file_paths(top_dir: str = ".") -> Iterator[str]:
3329
for dir_path, dir_names, filenames in os.walk(top_dir):
3430
dir_names[:] = [d for d in dir_names if d != "scripts" and d[0] not in "._"]
3531
for filename in filenames:
36-
if filename == "__init__.py":
37-
continue
38-
if any(
32+
if filename == "__init__.py" or any(
3933
e.lower() in os.path.join(dir_path, filename).lower() for e in ignore
4034
):
4135
continue
4236
if os.path.splitext(filename)[1] in sys.argv[2].split(","):
4337
path = os.path.join(dir_path, filename).lstrip(".").lstrip("/")
4438
for e in skip:
45-
path = path.replace(e + "/", "")
46-
path = path.replace(e + "\\", "")
39+
path = path.replace(f"{e}/", "").replace(f"{e}\\", "")
4740
yield path
4841

4942

0 commit comments

Comments
 (0)
0