-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
42 lines (30 loc) · 901 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
#!/usr/bin/env python
import os
HEADER="""# TIL
> Today I Learned
매일 배우는 개발 지식 모음
---
"""
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.upper() 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()