-
Notifications
You must be signed in to change notification settings - Fork 0
/
cv.py
55 lines (46 loc) · 1.83 KB
/
cv.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
import json
import shutil
import sys
from pylatex import Command, Document
from cv_sections import (competence, contact, education, experience, heading,
license, reward, work)
from cv_setups import colors, docsetup
from cv_setups import packages as pkgs
def fill_document(doc):
cv_file = open("./import/cv.json")
cv_data = json.load(cv_file)
heading.add_heading(doc, cv_data)
contact.add_contact(doc, cv_data)
experience.add_experience(doc, cv_data)
education.add_education(doc, cv_data)
work.add_work_experience(doc, cv_data)
license.add_license(doc, cv_data)
reward.add_reward(doc, cv_data)
competence.add_competence(doc, cv_data)
cv_file.close()
def build_cv(debug, compiler, filename="CV"):
documentclass = Command(
"documentclass", options=("letterpaper", "11pt"), arguments="article"
)
doc = Document(filename, documentclass=documentclass, fontenc=None, inputenc=None)
# add resume layout required packages
pkgs.add_packages(doc)
colors.add_colors(doc)
docsetup.setup_document(doc)
fill_document(doc)
# compile latex file and pdf file
doc.generate_tex()
doc.generate_pdf(clean=False, clean_tex=False, compiler=compiler)
doc.generate_pdf(
clean=(not debug), clean_tex=False, compiler=compiler
) # compile twice in order for transparent package to work, reference: https://tex.stackexchange.com/questions/297294/pdflatex-transparent-package-seems-not-to-work
# move files to export directory
shutil.move("./{0}.pdf".format(filename), "./export/{0}.pdf".format(filename))
shutil.move("./{0}.tex".format(filename), "./export/{0}.tex".format(filename))
if __name__ == "__main__":
compiler = None
try:
compiler = sys.argv[1]
except:
pass
build_cv(debug=False, compiler=compiler)