-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.py
53 lines (41 loc) · 1.16 KB
/
upload.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
import os
from urllib import parse
HEADER="""#
# 백준 문제 풀이 목록
"""
def main():
content = ""
content += HEADER
directories = []
solveds = []
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)
if category == 'images':
continue
directory = os.path.basename(os.path.dirname(root))
if directory == '.':
continue
if directory not in directories:
if directory in ["백준", "프로그래머스"]:
content += "## 📚 {}\n".format(directory)
else:
content += "### 🚀 {}\n".format(directory)
content += "| 문제번호 | 링크 |\n"
content += "| ----- | ----- |\n"
directories.append(directory)
for file in files:
if category not in solveds:
content += "|{}|[링크]({})|\n".format(category, parse.quote(os.path.join(root, file)))
solveds.append(category)
with open("README.md", "w") as fd:
fd.write(content)
if __name__ == "__main__":
main()