-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentries.py
31 lines (25 loc) · 1.09 KB
/
entries.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
import os
from operator import itemgetter
output = open("entries.tex", 'w')
entries = []
for dirname, dirnames, filenames in os.walk('entries'):
for subdirname in dirnames:
os.path.join(dirname, subdirname)
for filename in filenames:
if filename.endswith('.tex'): # Only include .tex files
dsplit = dirname.split('/') # Split path by directory
fsplit = filename.split(' - ') # Split file by date and title
texfile = {
'path': os.path.join(dirname) + "/" + filename[:-4],
'title': fsplit[1].split('.')[0],
'date': dsplit[1] + "-" + dsplit[2] + "-" + fsplit[0]
}
entries.append(texfile)
entries = sorted(entries, key=itemgetter('date'))
for e in entries:
# Writing the title, hspace and date
output.write("\\textbf{" + e['title'] + "} ")
output.write("\\hspace*{\\fill} ")
output.write("\\textbf{" + e['date'] + "}\\\\\n")
# Writing the input statement
output.write("\\input{\"" + e['path'] + "\"} \\bigskip\n\n")