Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/smefit/analyze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import pathlib
import shutil
import subprocess

import sys
import os
import yaml
from matplotlib import rc, use

Expand Down Expand Up @@ -69,14 +70,17 @@ def run_report(report_card_file):
# Move all files to a meta folder
meta_path = pathlib.Path(f"{report_folder}/meta").absolute()
meta_path.mkdir()
subprocess.call(f"mv {report_folder}/*.* {meta_path}", shell=True)
for f in report_folder.glob("*.*"):
shutil.move(str(f), meta_path)

# Combine PDF files together into raw pdf report
subprocess.call(
f"gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-sOutputFile={report_folder}/report_{report_name}.pdf `ls -rt {meta_path}/*.pdf`",
shell=True,
)
pdf_files = sorted(meta_path.glob("*.pdf"), key=os.path.getmtime)
gs_cmd = "gswin64c" if sys.platform == "win32" else "gs"
subprocess.call([
gs_cmd, "-q", "-dNOPAUSE", "-dBATCH", "-sDEVICE=pdfwrite",
f"-sOutputFile={report_folder}/report_{report_name}.pdf",
*[str(f) for f in pdf_files],
])

# dump html index
dump_html_index(
Expand Down
12 changes: 8 additions & 4 deletions src/smefit/analyze/html_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ def run_htlatex(report_path, tex_file):
new_style = report_path.joinpath("style.css")
shutil.copyfile(style_css, new_style)
# title = tex_file.stem.replace("_", " ")
subprocess.call(
f"pandoc {tex_file} --standalone --mathjax --output {tex_file.with_suffix('.html')} --metadata title=' ' -c {new_style.stem}.css",
shell=True,
)
subprocess.call([
"pandoc", str(tex_file),
"--standalone",
"--mathjax",
"--output", str(tex_file.with_suffix('.html')),
"--metadata", "title= ",
"-c", f"{new_style.stem}.css",
])


def dump_html_index(html_report, html_index, report_path, report_title):
Expand Down
5 changes: 4 additions & 1 deletion src/smefit/analyze/latex_tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import os
import pathlib
import subprocess

Expand Down Expand Up @@ -84,7 +85,9 @@ def run_pdflatex(report, filename):
f"pdflatex -halt-on-error -output-directory {report} {filename}.tex > {report}/pdflatex.log",
shell=True,
)
subprocess.call(f"rm {report}/*.log {report}/*.aux {report}/*.out", shell=True)
for ext in ["*.log", "*.aux", "*.out"]:
for f in report.glob(ext):
os.remove(f)


def compile_tex(report, L, filename):
Expand Down
Loading