-
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.
add process_tei.py script, adjust some scripts where needed
- Loading branch information
EsGeh
authored and
EsGeh
committed
Jan 7, 2020
1 parent
99107d1
commit 56a39f7
Showing
7 changed files
with
262 additions
and
134 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
This file was deleted.
Oops, something went wrong.
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
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,92 @@ | ||
#!/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 | ||
): | ||
PUBL_NAME = publ_dir.resolve().stem | ||
exec_command( | ||
f"tei_add_bibl.py -! \"{publ_dir}\"" | ||
) | ||
exec_command( | ||
f"tei2eoatex.py -! \"{publ_dir}\"" | ||
) | ||
exec_command( | ||
f"eoatex2pdf.py --output-dir \"{DEFAULT_OUTPUT_DIR}/{PUBL_NAME}/pdf\" \"{DEFAULT_OUTPUT_DIR}/{PUBL_NAME}/eoatex\"" | ||
) | ||
exec_command( | ||
f"tei_pickle.py -! \"{DEFAULT_OUTPUT_DIR}/with_bibl/{PUBL_NAME}\"" | ||
) | ||
exec_command( | ||
f"tei2imxml.py --filename no_bibl.xml \"{DEFAULT_OUTPUT_DIR}/with_bibl/{PUBL_NAME}\"" | ||
) | ||
exec_command( | ||
f"tei2html.py -! --filename \"with_bibl.xml\" \"{DEFAULT_OUTPUT_DIR}/with_bibl/{PUBL_NAME}\"" | ||
) | ||
|
||
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( | ||
"PUBLICATION_DIR", | ||
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 ) | ||
) |
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
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
Oops, something went wrong.