Skip to content

Commit

Permalink
Create update.py
Browse files Browse the repository at this point in the history
  • Loading branch information
boyamie authored Jun 10, 2024
1 parent e798542 commit 1353624
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python

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)
print("category : " + category)

with open("README.md", "w") as fd:
fd.write(content)

if __name__ == "__main__":
main()

0 comments on commit 1353624

Please sign in to comment.