From 3713c70ec0ba91d39aa5c402b488125befd8f9fd Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Wed, 31 May 2023 03:53:16 +0200 Subject: [PATCH] chore: cleaning --- program/README.md | 9 ++++++ program/code/functional_tests/texfile.tex | 15 +++++++++ .../code/functional_tests/texfile.tex.html | 1 + .../functional_tests/texfilecolumnswrong.tex | 7 ++++ .../texfilecolumnswrong.tex.html | 1 + .../code/functional_tests/texfilelonger.tex | 9 ++++++ .../functional_tests/texfilelonger.tex.html | 1 + program/code/latex_classes/latex_classes.py | 30 ------------------ program/code/main.py | 12 +++++-- program/code/texfile.pdf | Bin 3988 -> 0 bytes program/code/texfile.tex.html | 1 + program/tests/test_code/__init__.py | 0 .../latex_classes => unit_tests}/__init__.py | 0 .../test_code}/__init__.py | 0 .../test_code/test_begin_document.py | 0 .../test_code/test_begin_tabular.py | 0 .../test_code/test_document_class.py | 0 .../test_code/test_length_conversions.py | 0 .../test_code/test_only_pipes_and_space.py | 0 .../test_code/test_split_columns.py | 0 .../test_code/test_split_rows.py | 0 .../test_tabular_columns_parameters.py | 0 .../test_code/test_tabular_parameters.py | 0 .../test_tabular_required_parameters.py | 0 .../test_code/test_translate_column.py | 0 .../test_translate_inside_to_html.py | 0 26 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 program/README.md create mode 100644 program/code/functional_tests/texfile.tex create mode 100644 program/code/functional_tests/texfile.tex.html create mode 100644 program/code/functional_tests/texfilecolumnswrong.tex create mode 100644 program/code/functional_tests/texfilecolumnswrong.tex.html create mode 100644 program/code/functional_tests/texfilelonger.tex create mode 100644 program/code/functional_tests/texfilelonger.tex.html delete mode 100644 program/code/latex_classes/latex_classes.py delete mode 100644 program/code/texfile.pdf create mode 100644 program/code/texfile.tex.html delete mode 100644 program/tests/test_code/__init__.py rename program/{code/latex_classes => unit_tests}/__init__.py (100%) rename program/{tests => unit_tests/test_code}/__init__.py (100%) rename program/{tests => unit_tests}/test_code/test_begin_document.py (100%) rename program/{tests => unit_tests}/test_code/test_begin_tabular.py (100%) rename program/{tests => unit_tests}/test_code/test_document_class.py (100%) rename program/{tests => unit_tests}/test_code/test_length_conversions.py (100%) rename program/{tests => unit_tests}/test_code/test_only_pipes_and_space.py (100%) rename program/{tests => unit_tests}/test_code/test_split_columns.py (100%) rename program/{tests => unit_tests}/test_code/test_split_rows.py (100%) rename program/{tests => unit_tests}/test_code/test_tabular_columns_parameters.py (100%) rename program/{tests => unit_tests}/test_code/test_tabular_parameters.py (100%) rename program/{tests => unit_tests}/test_code/test_tabular_required_parameters.py (100%) rename program/{tests => unit_tests}/test_code/test_translate_column.py (100%) rename program/{tests => unit_tests}/test_code/test_translate_inside_to_html.py (100%) diff --git a/program/README.md b/program/README.md new file mode 100644 index 00000000..9c884d58 --- /dev/null +++ b/program/README.md @@ -0,0 +1,9 @@ +To run unit tests: +Enter project environment: + +source /ecote/bin/activate + +Run tests: + +python -m pytest unit_tests + diff --git a/program/code/functional_tests/texfile.tex b/program/code/functional_tests/texfile.tex new file mode 100644 index 00000000..0c46d149 --- /dev/null +++ b/program/code/functional_tests/texfile.tex @@ -0,0 +1,15 @@ +\documentclass{article} +\begin{document} +some random text +\begin{tabular}{c} + inside table +\end{tabular} +some random text 2 +\begin{tabular}{c} + inside table2 +\end{tabular} + +\begin{tabular}{c} + inside table3 +\end{tabular} +\end{document} \ No newline at end of file diff --git a/program/code/functional_tests/texfile.tex.html b/program/code/functional_tests/texfile.tex.html new file mode 100644 index 00000000..eeda3484 --- /dev/null +++ b/program/code/functional_tests/texfile.tex.html @@ -0,0 +1 @@ +some random text
inside table
some random text 2
inside table2
inside table3
\ No newline at end of file diff --git a/program/code/functional_tests/texfilecolumnswrong.tex b/program/code/functional_tests/texfilecolumnswrong.tex new file mode 100644 index 00000000..5f7a98e6 --- /dev/null +++ b/program/code/functional_tests/texfilecolumnswrong.tex @@ -0,0 +1,7 @@ +\documentclass{class} +\begin{document} +\begin{tabular}{ l c r } +1 & 2 & 3 \\ +4 & 5 6 \\ +\end{tabular} +\end{document} \ No newline at end of file diff --git a/program/code/functional_tests/texfilecolumnswrong.tex.html b/program/code/functional_tests/texfilecolumnswrong.tex.html new file mode 100644 index 00000000..33e82118 --- /dev/null +++ b/program/code/functional_tests/texfilecolumnswrong.tex.html @@ -0,0 +1 @@ +Error! \ No newline at end of file diff --git a/program/code/functional_tests/texfilelonger.tex b/program/code/functional_tests/texfilelonger.tex new file mode 100644 index 00000000..4bc0aa29 --- /dev/null +++ b/program/code/functional_tests/texfilelonger.tex @@ -0,0 +1,9 @@ +\documentclass{class} +\begin{document} +\begin{tabular}{ l | c | r } +test & 2 & test \\ +4 & 5 & 6 \\ +\end{tabular} +\end{document} +\end{lstlisting}& +\begin{lstlisting} \ No newline at end of file diff --git a/program/code/functional_tests/texfilelonger.tex.html b/program/code/functional_tests/texfilelonger.tex.html new file mode 100644 index 00000000..31ed8b4a --- /dev/null +++ b/program/code/functional_tests/texfilelonger.tex.html @@ -0,0 +1 @@ +
test 2 test
4 5 6
\ No newline at end of file diff --git a/program/code/latex_classes/latex_classes.py b/program/code/latex_classes/latex_classes.py deleted file mode 100644 index 616f1d46..00000000 --- a/program/code/latex_classes/latex_classes.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Holds an array of all classes from https://ctan.org/topic/class -""" -classes = [ - "article", - "report", - "book", - "beamer", - "letter", - "memoir", - "slides", - "IEEEtran", - "exam", - "amsart", - "amsbook", - "tufte-book", - "scrartcl", - "scrreprt", - "moderncv", - "cv", - "res", - "elsarticle", - "acm_proc_article-sp", - "scrbook", -] - - -def return_latex_classes(): - """Returns latex classes array""" - return classes diff --git a/program/code/main.py b/program/code/main.py index 53c328ff..f81ba830 100644 --- a/program/code/main.py +++ b/program/code/main.py @@ -217,6 +217,10 @@ def translate_inside_to_html(latex_table_inside, column_style): column_number = 0 for column in columns: return_string += "= len(column_style): + print( + f"Error! column_number index: {column_number} is out of length of column_style: {column_style}") + return "Error!" current_style = column_style[column_number] while current_style == line_string: return_string += line_string @@ -315,8 +319,7 @@ def handle_insides(html_string, data): return html_string, data -def main_function(): - tex_filename = "texfile.tex" +def main_function(tex_filename): data = read_file(tex_filename) html_string = "" html_string, data = read_start(html_string, data) @@ -329,4 +332,7 @@ def main_function(): if __name__ == "__main__": - print(main_function()) + tex_filename = "texfile.tex" + final_html = main_function(tex_filename) + f = open(tex_filename + ".html", "w") + f.write(final_html) diff --git a/program/code/texfile.pdf b/program/code/texfile.pdf deleted file mode 100644 index d2c1749d49aff0d20896c53bd164dc27f4eda2b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3988 zcma)Plz=$7c%!`}ATGAvXbrTTyFFS$7wzWg{fJuJ!d zLMOCX5U1@Qn!1*x)RE0{Z(zwt+b}|SFWvOdqgZ?tK3j+@)&vYSjn>f!+}Oy`7KfpH z?CfK8I1g8{{lX&) z_sY8=Q&wuwH^29qX%DkHT&=bnD308~nrS;E_0Wv2^lq_paCQ)#ra13YquuQPZ?<32 zA7X%j|BEV8Ai2M)Vm)qyi2wqK_Iy<|IqyOCZ7`OA;t8q`(}~lP$E-{1Br;TRuG8%- zLK!`c(0N)b|J?ejDV$1~;R*&b>()>Zx1cM{lOY{f9gSjvlr6hh5awKp1`iLJOdS=7 z_D6l-SAp+?^TfT1cxk6t)>iLLZq78)GL7Gl9{U_k!YEb~cM8%6nv|sT>nYt2Oz-Q5 zs^B-i3{oJrW?#6eVaL)Z#cIFlDv9_+6ZdG4NDR$B=0PM6+=OVdJrefc8}Cd=C@W{n zp)9$0>$bBp{w(Rj$hEtBHj+|}(ZLL!5N9ahyu_?kQ9a=>M%<{iTp?=`CTzH?KLao= z@yKE|Fd%txyP)9vv^eCppk>jc$d47O}YY5OIj$%32`8U z^W#B$QXGjSUP8Qro7**M_pLE{^^A?+KAlRQDuTOfx=u25_S>KZ?tLr5x846LVE*j# z^6LtI%e@I2mKO03eh3bp~atHeURgkO_^9 zU>r5)nT4vPt_$3;h~W<3@SUw6r5s5SUAc1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@TjT{iw&MOeirb zF5>{T?h6^y)?o`k^aR~LYm*fozuyx~KQ_D^HbmE^O{REVnw?GRC2ujQU%cdsX56M+ zFjoOz@~fE_&oO8=g?VzJ9D&C565maa3v9s8qsQnI=)l?|bbXVyFr`i5M&DM}a>I7^ z@IgzZeuR^A;c!Y|m67o>8vNin-fAxIso(g5VRm~duEfyl;^U`QVHIvV{fBO%3pbme z+i%)`rrJ<{`+ncvV%JJQPigV-H~$_I=+u`9`aP1o?S($VS6FgRhr^7bD?)XkNJIuZ z%?ees?IC4uvKR8}yT}$zO%Ie6YxqDU5YIc{y!U#i5_mhhy!tnppfl!+J-rdxR@m{% z`~)^e6Tuo*TWv0vG*J|}Y$JZ5KNjL8<$vqv+S5RBU$7=So-5#@d7RAh^$xu9vdd-b zL{jSwF=W*GoMe7RGWPFA2Fd(CCqFPkJ4iq^EEVNt<>jR0BvC-HthAhij6K-S7K8$W zWl?Ap3M>smEC2Tw))GeU?%vd(UoDIzpl%NC+<$x|j3kVm{L$PXu!OlK=vPM4`kzka z->%aRiTrU@7#kK5My>&jxCQ}q5%YdwW&6R#swzqW*~tgoWa2BOj_e)5zv1|RLKBim ng%>a=BoWcFB>C;X50CY>_44-fLOW1P$%3S*1q3t=Ak_Z?z|B41 diff --git a/program/code/texfile.tex.html b/program/code/texfile.tex.html new file mode 100644 index 00000000..eeda3484 --- /dev/null +++ b/program/code/texfile.tex.html @@ -0,0 +1 @@ +some random text
inside table
some random text 2
inside table2
inside table3
\ No newline at end of file diff --git a/program/tests/test_code/__init__.py b/program/tests/test_code/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/program/code/latex_classes/__init__.py b/program/unit_tests/__init__.py similarity index 100% rename from program/code/latex_classes/__init__.py rename to program/unit_tests/__init__.py diff --git a/program/tests/__init__.py b/program/unit_tests/test_code/__init__.py similarity index 100% rename from program/tests/__init__.py rename to program/unit_tests/test_code/__init__.py diff --git a/program/tests/test_code/test_begin_document.py b/program/unit_tests/test_code/test_begin_document.py similarity index 100% rename from program/tests/test_code/test_begin_document.py rename to program/unit_tests/test_code/test_begin_document.py diff --git a/program/tests/test_code/test_begin_tabular.py b/program/unit_tests/test_code/test_begin_tabular.py similarity index 100% rename from program/tests/test_code/test_begin_tabular.py rename to program/unit_tests/test_code/test_begin_tabular.py diff --git a/program/tests/test_code/test_document_class.py b/program/unit_tests/test_code/test_document_class.py similarity index 100% rename from program/tests/test_code/test_document_class.py rename to program/unit_tests/test_code/test_document_class.py diff --git a/program/tests/test_code/test_length_conversions.py b/program/unit_tests/test_code/test_length_conversions.py similarity index 100% rename from program/tests/test_code/test_length_conversions.py rename to program/unit_tests/test_code/test_length_conversions.py diff --git a/program/tests/test_code/test_only_pipes_and_space.py b/program/unit_tests/test_code/test_only_pipes_and_space.py similarity index 100% rename from program/tests/test_code/test_only_pipes_and_space.py rename to program/unit_tests/test_code/test_only_pipes_and_space.py diff --git a/program/tests/test_code/test_split_columns.py b/program/unit_tests/test_code/test_split_columns.py similarity index 100% rename from program/tests/test_code/test_split_columns.py rename to program/unit_tests/test_code/test_split_columns.py diff --git a/program/tests/test_code/test_split_rows.py b/program/unit_tests/test_code/test_split_rows.py similarity index 100% rename from program/tests/test_code/test_split_rows.py rename to program/unit_tests/test_code/test_split_rows.py diff --git a/program/tests/test_code/test_tabular_columns_parameters.py b/program/unit_tests/test_code/test_tabular_columns_parameters.py similarity index 100% rename from program/tests/test_code/test_tabular_columns_parameters.py rename to program/unit_tests/test_code/test_tabular_columns_parameters.py diff --git a/program/tests/test_code/test_tabular_parameters.py b/program/unit_tests/test_code/test_tabular_parameters.py similarity index 100% rename from program/tests/test_code/test_tabular_parameters.py rename to program/unit_tests/test_code/test_tabular_parameters.py diff --git a/program/tests/test_code/test_tabular_required_parameters.py b/program/unit_tests/test_code/test_tabular_required_parameters.py similarity index 100% rename from program/tests/test_code/test_tabular_required_parameters.py rename to program/unit_tests/test_code/test_tabular_required_parameters.py diff --git a/program/tests/test_code/test_translate_column.py b/program/unit_tests/test_code/test_translate_column.py similarity index 100% rename from program/tests/test_code/test_translate_column.py rename to program/unit_tests/test_code/test_translate_column.py diff --git a/program/tests/test_code/test_translate_inside_to_html.py b/program/unit_tests/test_code/test_translate_inside_to_html.py similarity index 100% rename from program/tests/test_code/test_translate_inside_to_html.py rename to program/unit_tests/test_code/test_translate_inside_to_html.py