-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathdircheck.py
73 lines (62 loc) · 1.77 KB
/
dircheck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""
Linter to ensure standard folder structure
"""
import pathlib
import re
import sys
IGNORELIST = {
"venv",
"asyncio-walkthrough",
"build-a-gui-with-wxpython",
"consuming-apis-python",
"flask-connexion-rest-part-3",
"flask-connexion-rest-part-4",
"generators",
"intro-to-threading",
"introduction-combining-data-pandas-merge-join-and-concat",
"linked-lists-python",
"nearbyshops",
"oop-in-java-vs-python",
"opencv-color-spaces",
"openpyxl-excel-spreadsheets-python",
"pygame-a-primer",
"pyqt-calculator-tutorial",
"python-dash",
"python-eval-mathrepl",
"rp-portfolio",
"storing-images",
"understanding-asynchronous-programming",
}
FOLDER_NAME_RE = re.compile(r"^[-a-z0-9]{5,}\Z")
has_errors = False
for f in sorted(pathlib.Path(".").glob("*")):
if not f.is_dir():
continue
if str(f).startswith("."):
continue
if str(f) in IGNORELIST:
continue
if not FOLDER_NAME_RE.search(str(f)):
print(
f"{f}: ensure folder name only uses "
f"lowercase letters, numbers, and hyphens"
)
has_errors = True
files = sorted(_.name for _ in f.glob("*"))
if "README.md" not in files:
print(f"{f}: no README.md found")
has_errors = True
if has_errors:
print(
"""-----------------------
Please ensure new sample projects are added using the correct
folder structure:
* New files should go into a top-level subfolder, named after the
article slug (lowercase, dashes). For example: my-awesome-article/
* Top-level sample project folders should contain a README.md file.
For example: my-awesome-article/README.md
This helps us keep the repo clean and easy to browse on GitHub.
Thanks!
"""
)
sys.exit(1)