-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_readme.py
More file actions
executable file
·28 lines (24 loc) · 837 Bytes
/
make_readme.py
File metadata and controls
executable file
·28 lines (24 loc) · 837 Bytes
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
#!/usr/bin/env python3
import os
from collections import OrderedDict
files_per_dir = OrderedDict((d, 0) for d in [
'code_jam',
'codeforces',
'cses',
'algorithms',
'leetcode',
])
for directory in files_per_dir:
for dirpath, dirnames, filepaths in os.walk(directory):
for filepath in filepaths:
if filepath in ['.DS_Store']:
continue
full_path = os.path.join(dirpath, filepath)
# print(full_path)
files_per_dir[directory] += 1
with open('readme.md', 'w') as f:
f.write('| Directory | # Problems |\n')
f.write('| --------- | ---------- |\n')
for directory, counts in files_per_dir.items():
f.write('| {} | {} |\n'.format(directory, counts))
print('readme updated!')