-
Notifications
You must be signed in to change notification settings - Fork 5
/
update.py
executable file
·47 lines (30 loc) · 935 Bytes
/
update.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
#!/usr/bin/env python
import os
HEADER="""# TIL
> Today I Learned
A collection of software engineering tips that I learn every day.
---
"""
def main():
content = ""
content += HEADER
for root, dirs, files in os.walk("."):
dirs.sort()
if root == '.':
for dir in ('.git', '.github'):
try:
dirs.remove(dir)
except ValueError:
pass
continue
category = os.path.basename(root)
content += "### {}\n\n".format(category)
for file in files:
name = os.path.basename(file).split('.')[0]
name = " ".join(word.capitalize() for word in name.split('-'))
content += "- [{}]({})\n".format(name, os.path.join(category, file))
content += "\n"
with open("README.md", "w") as fd:
fd.write(content)
if __name__ == "__main__":
main()