Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
967230c8
Commit
967230c8
authored
5 years ago
by
Mikhail Karnevskiy
Browse files
Options
Downloads
Patches
Plain Diff
Use os tools to work with file path
parent
0c897c3b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!70
Feat: vector graphics in the calibration report
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cal_tools/cal_tools/tools.py
+10
-9
10 additions, 9 deletions
cal_tools/cal_tools/tools.py
with
10 additions
and
9 deletions
cal_tools/cal_tools/tools.py
+
10
−
9
View file @
967230c8
...
...
@@ -62,34 +62,35 @@ def prepare_plots(run_path, threshold=1000000):
Convert svg file to pdf or png to be used for latex
Conversion of svg to vector graphics pdf is performed using svglib3.
This procedure is CPU consuming. In order to speeup process
This procedure is CPU consuming. In order to spee
d
up process
large svg files are converted to png format.
Link in rst files to converted image files are corrected respectively.
The links in the rst files are adapted accordingly to the
converted image files.
:param run_path: Run path of the slurm job
:param threshold: Max svg file size to be converted to pdf
:param threshold: Max svg file size
(in bytes)
to be converted to pdf
"""
print
(
'
Convert svg to pdf and png
'
)
run_path
=
os
.
path
.
abspath
(
run_path
)
files
=
glob
.
glob
(
'
{}/*_files/*svg
'
.
format
(
run_path
))
for
f_path
in
files
:
print
(
f_path
,
f_path
[
len
(
run
_path
)
:])
dir_name
,
f_name
=
f_
path
[
len
(
run_path
)
+
1
:].
split
(
'
/
'
)
dir_name
=
os
.
path
.
dirname
(
f
_path
)
f_name
=
os
.
path
.
basename
(
f_path
)
if
(
os
.
stat
(
f_path
)).
st_size
<
threshold
:
check_call
([
"
svg2pdf
"
,
"
{}
"
.
format
(
f_path
)],
shell
=
False
)
new_f_name
=
f_name
[:
-
4
]
+
'
.pdf
'
new_f_name
=
os
.
path
.
splitext
(
f_name
)[
0
]
+
'
.pdf
'
else
:
check_call
([
"
convert
"
,
"
{}
"
.
format
(
f_path
),
"
{}.png
"
.
format
(
f_path
[:
-
4
])],
shell
=
False
)
new_f_name
=
f_name
[:
-
4
]
+
'
.png
'
new_f_name
=
os
.
path
.
splitext
(
f_name
)[
0
]
+
'
.png
'
print
(
'
{} converted to {}
'
.
format
(
f_name
,
new_f_name
))
check_call
([
"
sed
"
,
"
-i
"
,
"
s/{}/{}/g
"
.
format
(
f_name
,
new_f_name
),
"
{}
/{}
.rst
"
.
format
(
run_path
,
dir_name
[:
-
6
])],
"
{}.rst
"
.
format
(
dir_name
[:
-
6
])],
shell
=
False
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment