diff --git a/src/process_sources14.py b/src/process_sources14.py new file mode 100755 index 0000000..4dc1d5c --- /dev/null +++ b/src/process_sources14.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 + +from utils.load_config import load_config, exec_command + +# imports +import argparse +from pathlib import Path +import glob +import os +import subprocess +import shutil +import logging + +BASE_DIR = Path( __file__ ).resolve().parent +SCRIPT_PATH = Path( __file__ ) +SCRIPT_NAME = SCRIPT_PATH.stem + +DEFAULT_INPUT_DIR = \ + Path(os.environ['INPUT_DIR'] if 'INPUT_DIR' in os.environ else './input') + +DEFAULT_OUTPUT_DIR = \ + Path(os.environ['OUTPUT_DIR'] if 'OUTPUT_DIR' in os.environ else './output') + +DEFAULT_DEPENDENCIES_DIR = \ + Path(os.environ['DEPENDENCIES_DIR'] if 'DEPENDENCIES_DIR' in os.environ else './dependencies') + +def main( + publ_dir +): + exec_command( + f"eoatex2pdf.py --include \"{publ_dir}\"" + ) + exec_command( + f"eoatex2imxml.py --no-math \"{publ_dir}\"" + ) + exec_command( + f"imxml2django.py \"{publ_dir}\"" + ) + exec_command( + f"imxml2epub.py \"{publ_dir}\"" + ) + +if __name__ == "__main__": + + ##################### + # Parsing arguments # + ##################### + + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + parser.add_argument( + "-c", "--config", + default = BASE_DIR / "config" / "eoaconvert.cfg", + dest="CONFIG_FILE", + help="Name of configuration file", + metavar="CONFIGURATION" + ) + parser.add_argument( + "-l", "--log-file", + default = (DEFAULT_OUTPUT_DIR / '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" + ) + parser.add_argument( + "-pd", + "--PUBLICATION_DIR", + default = "input/sources14", + help = "directory containing the publication (including resources like pictures, etc.)", + type = Path, +) + + args = parser.parse_args() + + CONFIG = load_config( + args.CONFIG_FILE, + args.log_level, + args.log_file, + ) + + main( + publ_dir = Path( args.PUBLICATION_DIR ) + )