Skip to content

Commit 0b58082

Browse files
committed
Add make_structure script
1 parent cc4dfdd commit 0b58082

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

make_structure.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
This script takes tab delimited input file like so and automatically
3+
creates the folder structure along with empty README files, per the contributing
4+
guidelines. If you copy-paste from Google sheets, it will automatically add
5+
tabs.
6+
7+
* Copy-paste the file below into `outline.txt` (too lazy to parameterize this
8+
script) in the directory of the module that you want to use, i.e.,
9+
`module5-testing/outline.txt`
10+
* cd to the correct directory (this step is important for the working directory
11+
to be correct)
12+
* Run `python ../make_structure.py`
13+
* Enjoy your created structure
14+
15+
1 What is a test?
16+
1.1 Why testing is important?
17+
2.1 Test-driven development
18+
2.2 Example code
19+
2.3 Properties of a good test
20+
3 Types of tests
21+
3.1 Popular testing libraries for JavaScript
22+
4 Testing lab
23+
"""
24+
import subprocess
25+
import sys
26+
import os
27+
28+
def main():
29+
with open('outline.txt', 'r') as f:
30+
text = f.read().strip().strip('\n')
31+
module_lines = text.split('\n')
32+
for line in module_lines:
33+
chapter_num, chapter_name = line.split('\t')
34+
35+
# Convert casing: "Example code" to "example-code"
36+
normalized_chapter_name = chapter_name.replace(' ', '-').lower()
37+
subprocess.run(["mkdir", "-p", os.path.join(os.getcwd(),
38+
normalized_chapter_name)])
39+
subprocess.run(["touch", os.path.join(os.getcwd(), normalized_chapter_name,
40+
"README.md")])
41+
42+
if __name__ == '__main__':
43+
main()

0 commit comments

Comments
 (0)