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
2cb30c04
Commit
2cb30c04
authored
6 years ago
by
Qing Tian
Browse files
Options
Downloads
Patches
Plain Diff
fixes to latex report generation.
parent
10ea22b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!49
Fixes to latex report generation in tools.py.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cal_tools/cal_tools/tools.py
+30
-14
30 additions, 14 deletions
cal_tools/cal_tools/tools.py
with
30 additions
and
14 deletions
cal_tools/cal_tools/tools.py
+
30
−
14
View file @
2cb30c04
...
@@ -39,11 +39,18 @@ def combine_report(run_path, calibration):
...
@@ -39,11 +39,18 @@ def combine_report(run_path, calibration):
gfile
.
write
(
"
=
"
*
len
(
title
)
+
"
\n
"
)
gfile
.
write
(
"
=
"
*
len
(
title
)
+
"
\n
"
)
gfile
.
write
(
"
\n
"
)
gfile
.
write
(
"
\n
"
)
with
open
(
"
{}/{}
"
.
format
(
run_path
,
entry
),
"
r
"
)
as
ifile
:
with
open
(
"
{}/{}
"
.
format
(
run_path
,
entry
),
"
r
"
)
as
ifile
:
skip_next
=
False
for
line
in
ifile
.
readlines
():
for
line
in
ifile
.
readlines
():
if
skip_next
:
skip_next
=
False
continue
if
conc_param
==
"
None
"
:
if
conc_param
==
"
None
"
:
gfile
.
write
(
line
)
gfile
.
write
(
line
)
elif
"
"
.
join
(
calibration
.
split
())
!=
"
"
.
join
(
line
.
split
()):
elif
"
"
.
join
(
calibration
.
split
())
!=
"
"
.
join
(
line
.
split
()):
gfile
.
write
(
line
)
gfile
.
write
(
line
)
else
:
skip_next
=
True
gfile
.
write
(
"
\n\n
"
)
gfile
.
write
(
"
\n\n
"
)
if
isdir
(
"
{}/{}
"
.
format
(
run_path
,
entry
)):
if
isdir
(
"
{}/{}
"
.
format
(
run_path
,
entry
)):
shutil
.
copytree
(
"
{}/{}
"
.
format
(
run_path
,
entry
),
"
{}/{}
"
.
format
(
sphinx_path
,
entry
))
shutil
.
copytree
(
"
{}/{}
"
.
format
(
run_path
,
entry
),
"
{}/{}
"
.
format
(
sphinx_path
,
entry
))
...
@@ -71,15 +78,22 @@ def make_report(run_path, tmp_path, out_path, project, author, version, report_t
...
@@ -71,15 +78,22 @@ def make_report(run_path, tmp_path, out_path, project, author, version, report_t
# now conf.py exists in temp folder, so add latex options to remove empty pages
# now conf.py exists in temp folder, so add latex options to remove empty pages
patch_path
=
"
{}
"
.
format
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
patch_path
=
"
{}
"
.
format
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
patch_file
=
(
"
{}/conf_latex.patch
"
.
format
(
patch_path
))
patch_file
=
(
"
{}/conf_latex.patch
"
.
format
(
patch_path
))
subprocess
.
check_call
([
"
patch
"
,
try
:
"
{}/sphinx_rep/conf.py
"
.
format
(
tmp_path
),
subprocess
.
check_call
([
"
patch
"
,
patch_file
])
"
{}/sphinx_rep/conf.py
"
.
format
(
tmp_path
),
patch_file
])
except
:
print
(
"
Patching latex conf failed
"
)
try
:
subprocess
.
check_call
([
"
sed
"
,
subprocess
.
check_call
([
"
sed
"
,
"
-i
"
,
"
-i
"
,
"
-e
"
,
"
-e
"
,
"
s/{}.tex/{}.tex/g
"
.
format
(
project
.
replace
(
"
"
,
""
),
report_name
),
"
s/{}.tex/{}.tex/g
"
.
format
(
project
.
replace
(
"
"
,
""
),
report_name
),
"
{}/sphinx_rep/conf.py
"
.
format
(
tmp_path
)],
shell
=
False
)
"
{}/sphinx_rep/conf.py
"
.
format
(
tmp_path
)],
shell
=
False
)
except
:
print
(
"
SEDing tex failed
"
)
except
subprocess
.
CalledProcessError
:
except
subprocess
.
CalledProcessError
:
raise
Exception
(
"
Failed to run sphinx-quickbuild. Is sphinx installed?
"
raise
Exception
(
"
Failed to run sphinx-quickbuild. Is sphinx installed?
"
...
@@ -94,22 +108,24 @@ def make_report(run_path, tmp_path, out_path, project, author, version, report_t
...
@@ -94,22 +108,24 @@ def make_report(run_path, tmp_path, out_path, project, author, version, report_t
if
isfile
(
"
{}/{}
"
.
format
(
run_path
,
entry
)):
if
isfile
(
"
{}/{}
"
.
format
(
run_path
,
entry
)):
name
,
ext
=
splitext
(
"
{}
"
.
format
(
entry
))
name
,
ext
=
splitext
(
"
{}
"
.
format
(
entry
))
if
ext
==
"
.rst
"
and
"
index
"
not
in
name
:
if
ext
==
"
.rst
"
and
"
index
"
not
in
name
:
files_to_handle
.
append
(
name
)
files_to_handle
.
append
(
name
.
strip
()
)
with
open
(
"
{}/index.rst.tmp
"
.
format
(
run_path
),
"
w
"
)
as
mf
:
with
open
(
"
{}/index.rst.tmp
"
.
format
(
run_path
),
"
w
"
)
as
mf
:
with
open
(
"
{}/index.rst
"
.
format
(
run_path
),
"
r
"
)
as
mfr
:
with
open
(
"
{}/index.rst
"
.
format
(
run_path
),
"
r
"
)
as
mfr
:
indexTmp
=
Template
(
'''
indexTmp
=
Template
(
'''
.. toctree::
.. toctree::
:maxdepth: 2
:maxdepth: 2
{% for k in keys %}
{% for k in keys %}
{{ k }}
{{ k }}
{%- endfor %}
{%- endfor %}
'''
)
'''
)
for
line
in
mfr
:
for
line
in
mfr
:
line
=
line
.
replace
(
"
.. toctree::
"
,
textwrap
.
dedent
(
line
=
line
.
replace
(
"
.. toctree::
"
,
textwrap
.
dedent
(
indexTmp
.
render
(
keys
=
files_to_handle
)))
indexTmp
.
render
(
keys
=
files_to_handle
)))
line
=
line
.
replace
(
"
:maxdepth: 2
"
,
""
)
line
=
line
.
replace
(
"
:maxdepth: 2
"
,
""
)
line
=
line
.
replace
(
"
Documentation
"
,
"
Calibration
"
)
line
=
line
.
replace
(
"
Documentation
"
,
"
Calibration
"
)
if
"
:caption.
"
in
line
:
continue
mf
.
write
(
line
)
mf
.
write
(
line
)
cdir
=
os
.
getcwd
()
cdir
=
os
.
getcwd
()
...
@@ -133,7 +149,7 @@ def make_report(run_path, tmp_path, out_path, project, author, version, report_t
...
@@ -133,7 +149,7 @@ def make_report(run_path, tmp_path, out_path, project, author, version, report_t
print
(
f
)
print
(
f
)
shutil
.
copy
(
f
,
out_path
)
shutil
.
copy
(
f
,
out_path
)
print
(
"
Removing temporary files at: {}
"
.
format
(
tmp_path
))
print
(
"
Removing temporary files at: {}
"
.
format
(
tmp_path
))
#
shutil.rmtree(tmp_path)
shutil
.
rmtree
(
tmp_path
)
def
finalize
(
joblist
,
run_path
,
out_path
,
project
,
calibration
,
author
,
version
,
report_to
):
def
finalize
(
joblist
,
run_path
,
out_path
,
project
,
calibration
,
author
,
version
,
report_to
):
...
...
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