|
4 | 4 | import sys
|
5 | 5 | from typing import Iterator
|
6 | 6 |
|
7 |
| -if(".py" in sys.argv[0]): |
| 7 | +if ".py" in sys.argv[0]: |
8 | 8 | sys.argv.pop(0)
|
9 | 9 |
|
10 | 10 |
|
11 |
| -if(len(sys.argv) < 3 or len(sys.argv) > 5): |
| 11 | +if len(sys.argv) not in (3, 4, 5): |
12 | 12 | print(
|
13 |
| - "Arguments:\n[0] - Language\n[1] - Base path\n[2] - Allowed filenames\n[3] - Files or folders to ignore (optional)\n[4] - Folders to ignore, but include children (optional)") |
14 |
| - exit(1) |
| 13 | + "Arguments:\n" |
| 14 | + "[0] - Language\n" |
| 15 | + "[1] - Base path\n" |
| 16 | + "[2] - Allowed filenames\n" |
| 17 | + "[3] - Files or folders to ignore (optional)\n" |
| 18 | + "[4] - Folders to ignore, but include children (optional)" |
| 19 | + ) |
| 20 | + sys.exit() |
15 | 21 |
|
16 | 22 | ignore = []
|
17 | 23 | skip = []
|
18 |
| -if(len(sys.argv) == 4): |
| 24 | +if len(sys.argv) == 4: |
19 | 25 | ignore = sys.argv[3].split(",")
|
20 |
| -if(len(sys.argv) == 5): |
| 26 | +if len(sys.argv) == 5: |
21 | 27 | skip = sys.argv[4].split(",")
|
22 | 28 |
|
23 |
| -URL_BASE = "https://github.com/TheAlgorithms/" + \ |
24 |
| - sys.argv[0] + "/blob/master" |
| 29 | +URL_BASE = f"https://github.com/TheAlgorithms/{sys.argv[0]}/blob/master" |
25 | 30 |
|
26 | 31 |
|
27 | 32 | def good_file_paths(top_dir: str = ".") -> Iterator[str]:
|
28 | 33 | for dir_path, dir_names, filenames in os.walk(top_dir):
|
29 |
| - dir_names[:] = [d for d in dir_names if d != |
30 |
| - "scripts" and d[0] not in "._"] |
| 34 | + dir_names[:] = [d for d in dir_names if d != "scripts" and d[0] not in "._"] |
31 | 35 | for filename in filenames:
|
32 | 36 | if filename == "__init__.py":
|
33 | 37 | continue
|
34 |
| - if any(e.lower() in os.path.join(dir_path, filename).lower() for e in ignore): |
| 38 | + if any( |
| 39 | + e.lower() in os.path.join(dir_path, filename).lower() for e in ignore |
| 40 | + ): |
35 | 41 | continue
|
36 | 42 | if os.path.splitext(filename)[1] in sys.argv[2].split(","):
|
37 | 43 | path = os.path.join(dir_path, filename).lstrip(".").lstrip("/")
|
@@ -68,5 +74,3 @@ def print_directory_md(top_dir: str = ".") -> None:
|
68 | 74 |
|
69 | 75 | if __name__ == "__main__":
|
70 | 76 | print_directory_md(sys.argv[1])
|
71 |
| - |
72 |
| - |
|
0 commit comments