Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fact_pdf_report
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
fact_pdf_report
Commits
c096ab8d
Commit
c096ab8d
authored
Jul 15, 2019
by
dorp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed 3.5 backwards compatibility (order of dict included)
parent
3db084f6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
27 deletions
+28
-27
template_engine.py
pdf_generator/tex_generation/template_engine.py
+21
-20
test_generator.py
test/unit/test_generator.py
+7
-7
No files found.
pdf_generator/tex_generation/template_engine.py
View file @
c096ab8d
import
logging
import
logging
from
base64
import
decodebytes
from
base64
import
decodebytes
from
collections
import
OrderedDict
from
pathlib
import
Path
from
pathlib
import
Path
from
time
import
localtime
,
strftime
from
time
import
localtime
,
strftime
...
@@ -42,26 +43,26 @@ def nice_number_filter(number):
...
@@ -42,26 +43,26 @@ def nice_number_filter(number):
def
filter_latex_special_chars
(
data
):
def
filter_latex_special_chars
(
data
):
latex_character_escapes
=
{
latex_character_escapes
=
OrderedDict
()
'
\\
'
:
''
,
latex_character_escapes
[
'
\\
'
]
=
''
'$'
:
'
\\
$'
,
latex_character_escapes
[
'
\'
'
]
=
''
'('
:
'$($'
,
latex_character_escapes
[
'$'
]
=
'
\\
$'
')'
:
'$)$'
,
latex_character_escapes
[
'('
]
=
'$($'
'['
:
'$[$'
,
latex_character_escapes
[
')'
]
=
'$)$'
']'
:
'$]
$'
,
latex_character_escapes
[
'['
]
=
'$[
$'
,
'#'
:
'
\\
#
'
,
latex_character_escapes
[
']'
]
=
'$]$
'
,
'
%
'
:
'
\\
%
'
,
latex_character_escapes
[
'#'
]
=
'
\\
#'
'&'
:
'
\\
&'
,
latex_character_escapes
[
'
%
'
]
=
'
\\
%
'
'_'
:
'
\\
_'
,
latex_character_escapes
[
'&'
]
=
'
\\
&'
'{'
:
'
\\
{'
,
latex_character_escapes
[
'_'
]
=
'
\\
_'
'}'
:
'
\\
}'
,
latex_character_escapes
[
'{'
]
=
'
\\
{'
'^'
:
'
\\
textasciicircum{}'
,
latex_character_escapes
[
'}'
]
=
'
\\
}'
'~'
:
'
\\
textasciitilde{}'
,
latex_character_escapes
[
'^'
]
=
'
\\
textasciicircum{}'
'>'
:
'
\\
textgreater{}'
,
latex_character_escapes
[
'~'
]
=
'
\\
textasciitilde{}'
'<'
:
'
\\
textless{}'
,
latex_character_escapes
[
'>'
]
=
'
\\
textgreater{}'
'
\n
'
:
'
\\
newline '
,
latex_character_escapes
[
'<'
]
=
'
\\
textless{}'
'
\'
'
:
'
'
latex_character_escapes
[
'
\n
'
]
=
'
\\
newline
'
}
for
character
,
replacement
in
latex_character_escapes
.
items
():
for
character
,
replacement
in
latex_character_escapes
.
items
():
if
character
in
data
:
if
character
in
data
:
data
=
data
.
replace
(
character
,
replacement
)
data
=
data
.
replace
(
character
,
replacement
)
...
...
test/unit/test_generator.py
View file @
c096ab8d
...
@@ -31,13 +31,13 @@ def test_execute_latex(monkeypatch, tmpdir):
...
@@ -31,13 +31,13 @@ def test_execute_latex(monkeypatch, tmpdir):
monkeypatch
.
setattr
(
'pdf_generator.generator.execute_shell_command_get_return_code'
,
exec_mock
)
monkeypatch
.
setattr
(
'pdf_generator.generator.execute_shell_command_get_return_code'
,
exec_mock
)
execute_latex
(
str
(
tmpdir
))
execute_latex
(
str
(
tmpdir
))
assert
Path
(
tmpdir
,
'test'
)
.
exists
()
assert
Path
(
str
(
tmpdir
)
,
'test'
)
.
exists
()
assert
Path
(
tmpdir
,
'test'
)
.
read_text
()
==
'works'
assert
Path
(
str
(
tmpdir
)
,
'test'
)
.
read_text
()
==
'works'
def
test_copy_fact_image
(
tmpdir
):
def
test_copy_fact_image
(
tmpdir
):
copy_fact_image
(
str
(
tmpdir
))
copy_fact_image
(
str
(
tmpdir
))
assert
Path
(
tmpdir
,
'fact_logo.png'
)
.
exists
()
assert
Path
(
str
(
tmpdir
)
,
'fact_logo.png'
)
.
exists
()
def
test_create_report_filename
():
def
test_create_report_filename
():
...
@@ -60,8 +60,8 @@ def test_create_templates(monkeypatch, tmpdir):
...
@@ -60,8 +60,8 @@ def test_create_templates(monkeypatch, tmpdir):
monkeypatch
.
setattr
(
'pdf_generator.generator.Engine'
,
MockEngine
)
monkeypatch
.
setattr
(
'pdf_generator.generator.Engine'
,
MockEngine
)
create_templates
(
analysis
=
{
'test'
:
{
'result'
:
'data'
}},
meta_data
=
{},
tmp_dir
=
str
(
tmpdir
))
create_templates
(
analysis
=
{
'test'
:
{
'result'
:
'data'
}},
meta_data
=
{},
tmp_dir
=
str
(
tmpdir
))
assert
Path
(
tmpdir
,
'main.tex'
)
.
exists
()
assert
Path
(
str
(
tmpdir
)
,
'main.tex'
)
.
exists
()
assert
Path
(
tmpdir
,
'meta.tex'
)
.
exists
()
assert
Path
(
str
(
tmpdir
)
,
'meta.tex'
)
.
exists
()
assert
Path
(
tmpdir
,
'test.tex'
)
.
exists
()
assert
Path
(
str
(
tmpdir
)
,
'test.tex'
)
.
exists
()
assert
Path
(
tmpdir
,
'test.tex'
)
.
read_text
()
==
'{"result": "data"}'
assert
Path
(
str
(
tmpdir
)
,
'test.tex'
)
.
read_text
()
==
'{"result": "data"}'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment