Skip to content

Commit

Permalink
Add command line option include
Browse files Browse the repository at this point in the history
This makes it possible to use the LaTeX command \include rather thatn
\input and simplifies debugging of parts of a publication
  • Loading branch information
kthoden committed Jun 28, 2021
1 parent 8a3c714 commit 1e340db
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/eoatex2pdf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

from utils.load_config import load_config, check_executable, exec_command, copy_dir_overwrite
from utils.load_config import load_config, check_executable, exec_command, copy_dir_overwrite, copy_dir_keepaux
import utils.libeoaconvert as libeoaconvert

import argparse
Expand All @@ -25,7 +25,8 @@
def main(
input_file,
output_dir,
nobiber
nobiber,
include
):
check_executable( "xelatex" )
if( not os.path.exists( output_dir ) ):
Expand All @@ -46,10 +47,16 @@ def main(
output_file = fixed_file_path,
pdf_or_xml = "pdf"
)
copy_dir_overwrite(
if include:
copy_dir_keepaux(
input_dir / "texfiles",
output_dir / "texfiles"
)
)
else:
copy_dir_overwrite(
input_dir / "texfiles",
output_dir / "texfiles"
)
copy_dir_overwrite(
input_dir / "preambel",
output_dir / "preambel"
Expand Down Expand Up @@ -135,6 +142,12 @@ def copy_bib_file():
default = False,
help="Run only two passes of XeLaTeX and no biber."
)
parser.add_argument(
"--include",
action="store_true",
default = False,
help="Use include rather than input and keep aux files in output directory."
)
parser.add_argument(
"INPUT_DIR",
help = "directory containing the publication (including resources like pictures, etc.)",
Expand All @@ -160,5 +173,6 @@ def copy_bib_file():
main(
input_file = input_file,
output_dir = output_dir,
nobiber = args.no_biber
nobiber = args.no_biber,
include = args.include
)
11 changes: 11 additions & 0 deletions src/utils/load_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import shlex
import time
import shutil
import glob

import tempfile

Expand All @@ -24,6 +25,16 @@ def copy_dir_overwrite( src, dst ):
shutil.rmtree( dst )
shutil.copytree( src, dst)

def copy_dir_keepaux(src, dst):
if os.path.exists( dst ):
for filename in glob.glob(os.path.join(dst, '*.tex')):
os.unlink(filename)
else:
os.mkdir(dst)
for filename in glob.glob(os.path.join(src, '*.tex')):
shutil.copy(filename, dst)


class ToFile:
def __init__( self, filename ):
self.filename = filename
Expand Down

0 comments on commit 1e340db

Please sign in to comment.