Repository navigation
Expand file tree
/
Copy pathcreate.py
More file actions
65 lines (45 loc) · 1.33 KB
/
Copy pathcreate.py
File metadata and controls
65 lines (45 loc) · 1.33 KB
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
65
# Function which create a texfile and a pdf,
# with the current invoice-data
import os, sys, subprocess
from settings import *
from output import mprint
from helpers import *
def writepdf(path):
print(path)
command = "pdflatex -etex -output-directory={} -interaction=nonstopmode {}".format(".",path)
p = subprocess.Popen(command, shell = True)
p.wait()
def create():
fkt = "create.create"
if os.path.isfile(fil_cur) == False:
mprint(fkt,1,"Current Invoice id doesnt exists. Exiting")
sys.exit(5)
# Read the current id from current-file
id = readcid()
# read the blueprint tex-file
try:
texfile = open(fil_pattern, "r")
except:
mprint(fkt,1,"No blueprint exists. Exiting")
sys.exit()
texfilestr = texfile.read()
# read the invoice-data from object-files
fol_obj = os.path.join(fol_invobjects,id)
objdata = invdata
for i in objdata:
f = open(os.path.join(fol_obj,i[0]), "r")
i[1] = f.readline()
f.close()
# create the substitute - list
for i in objdata:
i[0] = r"\$" + i[0]
# substitute !
texfilestr = subinstr(objdata,texfilestr)
# create output tex-file
fil_texsrc = os.path.join(fol_obj,"src.tex")
f = open(fil_texsrc, "w")
f.write(texfilestr)
f.close
mprint(fkt,1,"Texfile written.")
# creating the pdf in the root-folder
writepdf(fil_texsrc)