-
Notifications
You must be signed in to change notification settings - Fork 3
/
makeinfo.py
32 lines (25 loc) · 1.2 KB
/
makeinfo.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
from sys import argv
from pyPdf import PdfFileReader
from os import path
filename = argv[1]
document = PdfFileReader(file(filename, "rb"))
pages = document.getNumPages()
with open(filename+".info", 'w') as out:
basedir = path.dirname(filename)
if basedir:
basedir += '/'
out.write("""import json
def UpdateInfo():
global FileName, FileList, PageCount
global DocumentTitle
global Pcurrent, Pnext, Tcurrent, Tnext, InitialPage
global RTrunning, RTrestart, StartTime, PageEnterTime, CurrentTime
with open('"""+basedir+"""json.txt', 'w') as io:
json.dump(({"page_count": PageCount, "current_page": Pcurrent, "previous_page": Pnext, "start_time": StartTime, "pageenter_time": PageEnterTime, "current_time": CurrentTime, "notes": PageProps[Pcurrent]['notes']}), io)
PageProps = {
""")
for i in range(1,pages + 1):
if i < pages:
out.write(" "+str(i)+": {\n 'transition': None,\n 'overview': True,\n 'notes': '',\n 'OnEnter': UpdateInfo\n },\n")
else:
out.write(" "+str(i)+": {\n 'transition': None,\n 'overview': True,\n 'notes': '',\n 'OnEnter': UpdateInfo\n }\n}")