-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kthoden
committed
Jun 28, 2021
1 parent
1e340db
commit c56f1a2
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ) | ||
) |