Skip to content

Commit 044ee05

Browse files
Padraig GleesonPadraig Gleeson
authored andcommitted
Update for comp on Mac
1 parent fffa0a3 commit 044ee05

File tree

1 file changed

+29
-21
lines changed
  • Part_1_Resources_for_computational_modellers

1 file changed

+29
-21
lines changed

Part_1_Resources_for_computational_modellers/compile.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
11
import os
2+
import sys
23
from subprocess import call
34

45
from pdfrw import PdfReader, PdfWriter
56

67
sections = ['Introduction','1_Experimental_datasets', '2_Structured_data_from_literature', '3_Analysis_tools', '4_Simulation_environments', '5_Model_sharing', '6_Computing_infrastructure', '7_Open_source_initiatives', '8_Web_portals']
78
#sections = ['Introduction','1_Experimental_datasets', '2_Structured_data_from_literature']
89

10+
only_sec = None
11+
12+
if len(sys.argv) == 2:
13+
only_sec = sys.argv[1]
14+
print("Only doing sections starting with %s"%only_sec)
915

1016
for section in sections:
1117

12-
print("++++++++++++++++++++++++++++++++++\n+ Adding section: %s\n+"%section)
13-
big_file = PdfWriter()
14-
15-
files = os.listdir(section)
16-
17-
files = sorted(files)
18-
19-
for f in files:
20-
fpath = section+'/'+f
21-
if os.path.isfile(fpath) and fpath.endswith('pptx') and not f=='Template.pptx':
22-
print("+ Incorporating: %s"%fpath)
23-
call(["libreoffice", "--headless", "--invisible", "--convert-to", "pdf", fpath])
24-
pdf_file_name = f.replace('pptx','pdf')
25-
26-
pdf_file = PdfReader(pdf_file_name)
27-
print("+ Adding pages from %s\n+"%pdf_file_name)
28-
big_file.addpages(pdf_file.pages)
29-
call(["mv", pdf_file_name, "temp"])
30-
31-
32-
big_file.write('Part1_%s.pdf'%section)
18+
if only_sec==None or section.startswith(only_sec):
19+
print("++++++++++++++++++++++++++++++++++\n+ Adding section: %s\n+"%section)
20+
big_file = PdfWriter()
21+
22+
files = os.listdir(section)
23+
24+
files = sorted(files)
25+
26+
for f in files:
27+
fpath = section+'/'+f
28+
if os.path.isfile(fpath) and fpath.endswith('pptx') and not f=='Template.pptx':
29+
print("+ Incorporating: %s"%fpath)
30+
call(["/Applications/LibreOffice.app/Contents/MacOS/soffice", "--headless", "--invisible", "--convert-to", "pdf", fpath])
31+
pdf_file_name = f.replace('pptx','pdf')
32+
33+
pdf_file = PdfReader(pdf_file_name)
34+
print("+ Adding pages from %s\n+"%pdf_file_name)
35+
big_file.addpages(pdf_file.pages)
36+
if not 'ICG' in pdf_file_name:
37+
call(["mv", pdf_file_name, "temp"])
38+
39+
40+
big_file.write('Part1_%s.pdf'%section)
3341

3442

3543
print("Done.")

0 commit comments

Comments
 (0)