forked from alexpizarroj/acm-icpc-trd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-contents.py
30 lines (23 loc) · 1009 Bytes
/
build-contents.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
import os.path
def prettify(fn):
fn = ' '.join(x[0].upper() + x[1:] for x in fn.lower().split('-') if x != '')
return fn
if __name__ == '__main__':
supported_src = {'.cpp': '\\includecpp', '.java': '\\includejava'};
working_dir = os.path.normpath(os.getcwd())
working_dir = os.path.join(working_dir, "src")
for dn in os.listdir(working_dir):
dirpath = os.path.join(working_dir, dn)
if not os.path.isdir(dirpath):
continue
section = prettify(dn)
print ("\\section{%s}" % (section))
for fn in os.listdir(dirpath):
filepath = os.path.join(dirpath, fn)
_, file_ext = os.path.splitext(filepath)
if not (os.path.isfile(filepath) and file_ext in supported_src.keys()):
continue
subsection = prettify(fn[:-len(file_ext)])
file_relpath = os.path.join(".", os.path.relpath(filepath))
file_relpath = file_relpath.replace('\\', '/')
print ("%s{%s}{%s}" % (supported_src[file_ext], subsection, file_relpath))