Initial commit
This commit is contained in:
0
banking_breakdown/__init__.py
Normal file
0
banking_breakdown/__init__.py
Normal file
13
banking_breakdown/__main__.py
Normal file
13
banking_breakdown/__main__.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import pandas as pd
|
||||
from banking_breakdown import latex_generator
|
||||
|
||||
|
||||
def main():
|
||||
src = latex_generator.generate_latex()
|
||||
latex_generator.build_document(src)
|
||||
# df = pd.read_csv('res/statement.csv', delimiter=';')
|
||||
# print(df['Betrag'])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
70
banking_breakdown/latex_generator.py
Normal file
70
banking_breakdown/latex_generator.py
Normal file
@@ -0,0 +1,70 @@
|
||||
import subprocess
|
||||
import textwrap
|
||||
import os
|
||||
import shutil
|
||||
import docker
|
||||
|
||||
|
||||
def generate_latex() -> str:
|
||||
result = textwrap.dedent("""\
|
||||
\\documentclass{article}
|
||||
|
||||
% Packages necessary for common.tex
|
||||
\\usepackage{amsmath}
|
||||
\\usepackage{pgfplots}
|
||||
\\pgfplotsset{compat=newest}
|
||||
|
||||
% Other packages
|
||||
\\usepackage{float}
|
||||
\\usepackage{subcaption}
|
||||
\\usepackage[a4paper, total={6.5in, 9in}]{geometry}
|
||||
\\usetikzlibrary{positioning}
|
||||
\\usepackage{ifthen}
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%% Set common options %%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
\\input{../lib/latex-common/common.tex}
|
||||
\\pgfplotsset{colorscheme/rocket}
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%%% Actual Document %%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
\\title{Banking Report}
|
||||
\\author{}
|
||||
|
||||
|
||||
\\begin{document}
|
||||
|
||||
\\maketitle
|
||||
|
||||
Test
|
||||
|
||||
|
||||
\\end{document}
|
||||
""")
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def build_document(src: str):
|
||||
os.makedirs(os.path.dirname("build/doc.tex"), exist_ok=True)
|
||||
with open("build/doc.tex", "w") as out_file:
|
||||
out_file.write(src)
|
||||
|
||||
shutil.copyfile("res/.latexmkrc", "build/.latexmkrc")
|
||||
|
||||
subprocess.call("docker build . -f res/Dockerfile.alpine"
|
||||
" -t banking-breakdown",
|
||||
shell=True)
|
||||
subprocess.call("docker run --rm -u `id -u`:`id -g`"
|
||||
" -v $(realpath .):/project"
|
||||
" -w /project/build banking-breakdown"
|
||||
" latexmk -pdf doc.tex",
|
||||
shell=True)
|
||||
Reference in New Issue
Block a user