Skip to content
Snippets Groups Projects
Commit 2a6a90d1 authored by Mikhail Karnevskiy's avatar Mikhail Karnevskiy
Browse files

Avoid direct work with string indexing

parent 17af5be9
No related branches found
No related tags found
1 merge request!70Feat: vector graphics in the calibration report
......@@ -73,25 +73,31 @@ def prepare_plots(run_path, threshold=1000000):
"""
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:
dir_name = os.path.dirname(f_path)
f_name = os.path.basename(f_path)
rst_files = glob.glob('{}/*rst'.format(run_path))
for rst_file in rst_files:
rst_file_name = os.path.basename(rst_file)
rst_file_name = os.path.splitext(rst_file_name)[0]
if (os.stat(f_path)).st_size < threshold:
check_call(["svg2pdf", "{}".format(f_path)], shell=False)
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 = os.path.splitext(f_name)[0] + '.png'
check_call(["sed",
"-i",
"s/{}/{}/g".format(f_name, new_f_name),
"{}.rst".format(dir_name[:-6])],
shell=False)
svg_files = glob.glob(
'{}/{}_files/*svg'.format(run_path, rst_file_name))
for f_path in svg_files:
f_name = os.path.basename(f_path)
f_name = os.path.splitext(f_name)[0]
if (os.stat(f_path)).st_size < threshold:
check_call(["svg2pdf", "{}".format(f_path)], shell=False)
new_ext = 'pdf'
else:
check_call(["convert", "{}".format(f_path),
"{}.png".format(f_name)], shell=False)
new_ext = 'png'
check_call(["sed",
"-i",
"s/{}.svg/{}.{}/g".format(f_name, f_name, new_ext),
rst_file],
shell=False)
def make_report(run_path, tmp_path, out_path, project, author, version, report_to):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment