Initial commit
This commit is contained in:
commit
df9d01baa5
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.idea/
|
||||||
|
__pycache__/
|
||||||
|
venv/
|
||||||
|
build/
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "lib/latex-common"]
|
||||||
|
path = lib/latex-common
|
||||||
|
url = ssh://git@git.mercurial-manifold.eu:2224/an.tsouchlos/latex-common.git
|
||||||
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)
|
||||||
1
lib/latex-common
Submodule
1
lib/latex-common
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit bded242752b51c685fd6ed21a3506733476d5842
|
||||||
3
res/.latexmkrc
Normal file
3
res/.latexmkrc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
$pdflatex="pdflatex -shell-escape -interaction=nonstopmode -synctex=1 %O %S";
|
||||||
|
$out_dir = 'build';
|
||||||
|
$pdf_mode = 1;
|
||||||
4
res/Dockerfile.alpine
Normal file
4
res/Dockerfile.alpine
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
FROM alpine:3.19
|
||||||
|
|
||||||
|
RUN apk update && apk upgrade
|
||||||
|
RUN apk add make texlive texmf-dist-pictures
|
||||||
Loading…
Reference in New Issue
Block a user