Skip to content
Permalink
387e9522da
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 112 lines (104 sloc) 2.93 KB
#!/usr/bin/env python3
from utils.load_config import load_config, check_executable, exec_command, copy_dir_overwrite
import utils.libeoaconvert as libeoaconvert
import argparse
from pathlib import Path
import logging
import os
import sys
import shutil
import pathlib
BASE_DIR = Path( __file__ ).resolve().parent
SCRIPT_PATH = Path( __file__ )
SCRIPT_NAME = SCRIPT_PATH.stem
def main(
input_file,
output_dir
):
check_executable( "xelatex" )
if( not os.path.exists( output_dir ) ):
os.makedirs( output_dir )
input_file = Path( input_file )
input_dir = input_file.resolve().parent
output_dir = Path( output_dir )
fixed_file_path = output_dir / input_file.name
libeoaconvert.enable_preamble(
input_file = input_file,
output_file = fixed_file_path,
pdf_or_xml = "pdf"
)
copy_dir_overwrite(
input_dir / "texfiles",
output_dir / "texfiles"
)
copy_dir_overwrite(
input_dir / "preambel",
output_dir / "preambel"
)
if (input_dir / "images").exists():
copy_dir_overwrite(
input_dir / "images",
output_dir / "images"
)
if (input_dir / "facsim").exists():
copy_dir_overwrite(
input_dir / "facsim",
output_dir / "facsim"
)
output_dir = output_dir.resolve()
cwd = Path.cwd()
os.chdir( output_dir )
logging.info( "cd {}".format( output_dir ) )
exec_command(
f"xelatex --halt-on-error {input_file.name}",
)
exec_command(
"biber {}".format( input_file.stem ),
)
exec_command(
f"xelatex --halt-on-error {input_file.name}",
)
exec_command(
f"xelatex --halt-on-error {input_file.name}",
)
logging.info( "cd {}".format( cwd ) )
os.chdir( cwd )
if __name__ == '__main__':
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"-f", "--filename",
required = True,
help="Name of main EOATeX file"
)
parser.add_argument(
"-o", "--output-dir",
default = "./output/latex",
help = "output directory"
)
parser.add_argument(
"-c", "--config",
default = BASE_DIR / "config" / "eoaconvert.cfg",
help="Name of config file"
)
parser.add_argument(
"-l", "--log-file",
default = Path("output/logs", SCRIPT_NAME).with_suffix(".log"),
help="logfile"
)
parser.add_argument(
"--log-level",
default = "INFO",
help="log level: choose between DEBUG, INFO, WARNING, ERROR, CRITICAL"
)
args = parser.parse_args()
load_config(
args.config,
args.log_level,
args.log_file
)
main(
input_file = args.filename,
output_dir = args.output_dir
)