Initial commit

This commit is contained in:
Andreas Tsouchlos 2023-12-30 01:12:50 +01:00
commit df9d01baa5
9 changed files with 101 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.idea/
__pycache__/
venv/
build/

3
.gitmodules vendored Normal file
View 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

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# banking-breakdown
Visualize banking statements.

View File

View 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()

View 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

@ -0,0 +1 @@
Subproject commit bded242752b51c685fd6ed21a3506733476d5842

3
res/.latexmkrc Normal file
View 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
View File

@ -0,0 +1,4 @@
FROM alpine:3.19
RUN apk update && apk upgrade
RUN apk add make texlive texmf-dist-pictures