-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
64 lines (54 loc) · 1.45 KB
/
tasks.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from invoke import task
from pathlib import Path
basepath = "."
open_cmd = "open"
overleaf = "/home/michael/Dropbox\ \(MLS\)/Apps/Overleaf/gbi"
fig_names = {
"1": "paper/fig1",
"2": "paper/fig2",
"3": "paper/fig3",
"4": "paper/fig4",
"5": "paper/fig5",
}
@task
def syncOverleaf(c, fig):
c.run(
"cp ./{fn}/fig/*.pdf {ol}/figures/ ".format(
bp=basepath, fn=fig_names[fig], ol=overleaf
)
)
c.run(
"cp ./{fn}/fig/*.png {ol}/figures/ ".format(
bp=basepath, fn=fig_names[fig], ol=overleaf
)
)
@task
def convert(c, fig):
_convertsvg2pdf(c, fig)
_convertpdf2png(c, fig)
@task
def _convertsvg2pdf(c, fig):
if fig is None:
for f in range(len(fig_names)):
_convert_svg2pdf(c, str(f + 1))
return
pathlist = Path("{bp}/{fn}/fig/".format(bp=basepath, fn=fig_names[fig])).glob(
"*.svg"
)
for path in pathlist:
c.run("inkscape {} --export-pdf={}.pdf".format(str(path), str(path)[:-4]))
@task
def _convertpdf2png(c, fig):
if fig is None:
for f in range(len(fig_names)):
_convert_pdf2png(c, str(f + 1))
return
pathlist = Path("{bp}/{fn}/fig/".format(bp=basepath, fn=fig_names[fig])).glob(
"*.pdf"
)
for path in pathlist:
c.run(
'inkscape {} --export-png={}.png -b "white" --export-dpi=250'.format(
str(path), str(path)[:-4]
)
)