Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Instead of bailing out, create directory and copy files
  • Loading branch information
Klaus Thoden committed May 31, 2018
1 parent 4274de2 commit 36d0bb8
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions eoatex2imxml.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2018-04-23 10:06:41 (kthoden)>
# Time-stamp: <2018-05-31 12:25:32 (kthoden)>

# license?
__version__= "1.0"
Expand Down Expand Up @@ -58,6 +58,11 @@
# run biber_2.1 -O biber2-1n.bbl $INPUT to obtain this file
BIBERFILE = "biber2-1.bbl"

########################
# Constant directories #
########################
CONVERT_DIR = os.getcwd() + os.path.sep + "CONVERT"

##################################
# Reading the configuration file #
##################################
Expand Down Expand Up @@ -356,7 +361,7 @@ def cleanup():
# Checking for existance of tools and libraries #
#################################################
if not os.path.exists(TRALICS_PATH_LIB):
print ("Cannot find the Tralics configuration at %s. Exiting." % TRALICS_PATH_LIB)
print("Cannot find the Tralics configuration at %s. Exiting." % TRALICS_PATH_LIB)
sys.exit()

##################################
Expand All @@ -371,15 +376,26 @@ def cleanup():
os.mkdir(os.getcwd() + "/debug")

# Check for folder and necessary files
if not os.path.exists(os.getcwd() + "/CONVERT"):
print ("Das notwendige Verzeichnis CONVERT wurde noch nicht erstellt.")
sys.exit()
if not os.path.exists(os.getcwd() + "/CONVERT/cover.jpg"):
print ("Die Datei cover.jpg im Verzeichnis CONVERT fehlt.")
sys.exit()
if not os.path.exists(os.getcwd() + "/CONVERT/publication.cfg"):
print ("Die Datei publication.cfg im Verzeichnis CONVERT fehlt.")
sys.exit()
if not os.path.exists(CONVERT_DIR):
print("The directory CONVERT has not been created yet. Creating it for you")
time.sleep(1)
os.makedirs(CONVERT_DIR)
if not os.path.exists(CONVERT_DIR + os.path.sep + "publication.cfg"):
print("The publication.cfg file is missing in CONVERT directory.")
if os.path.exists(os.getcwd() + os.path.sep + "publication.cfg"):
shutil.copy("publication.cfg", CONVERT_DIR)
print("Copied from current directory.")
else:
print("Found no publication.cfg. Exiting")
sys.exit()
if not os.path.exists(CONVERT_DIR + os.path.sep + "cover.jpg"):
print("The file Cover.jpg in CONVERT directory is missing.")
if os.path.exists(os.getcwd() + os.path.sep + "Cover.jpg"):
shutil.copy("Cover.jpg", CONVERT_DIR + os.path.sep + "cover.jpg")
print("Copied from current directory.")
else:
print("No coverfile found. You can create a temporary one with the mkimage.py script")
sys.exit()
# if os.path.exists(os.getcwd() + "/pre_xml.tex") == False:
# print ("pre_xml fehlt")
# sys.exit()
Expand Down Expand Up @@ -1295,8 +1311,8 @@ def cleanup():
form_cit = BeautifulSoup(formatted_citations, "html.parser")

for xmlChapter in xmlChapters:
print ("-----------------------------------------------------")
print ("Processing References for Chapter " + str(intChapterNumber))
print("-----------------------------------------------------")
print("Processing References for Chapter " + str(intChapterNumber))
xmlCitations = xmlChapter.xpath(".//EOAciteauthoryear | .//EOAciteyear | .//EOAcitemanual")

if bib_type == "anthology":
Expand Down

0 comments on commit 36d0bb8

Please sign in to comment.