Skip to content

Commit

Permalink
Updated pandoc_download platform handles to check for pandoc-citeproc…
Browse files Browse the repository at this point in the history
… before trying to copy, instead of throwing an error reactively (#311)
  • Loading branch information
JessicaTegner authored Oct 28, 2022
1 parent 69ca1f7 commit 6aa5541
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pypandoc/pandoc_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ def _handle_linux(filename, targetfolder):
exe = "pandoc-citeproc"
src = os.path.join(tempfolder, "usr", "bin", exe)
dst = os.path.join(targetfolder, exe)
logger.info(f"Copying {exe} to {targetfolder} ...")
try:
if os.path.exists(src):
logger.info(f"Copying {exe} to {targetfolder} ...")
shutil.copyfile(src, dst)
_make_executable(dst)
except FileNotFoundError:
logger.exception("Didn't copy pandoc-citeproc")
src = os.path.join(tempfolder, "usr", "share", "doc", "pandoc", "copyright")
dst = os.path.join(targetfolder, "copyright.pandoc")
logger.info(f"Copying copyright to {targetfolder} ...")
Expand Down Expand Up @@ -151,12 +149,10 @@ def _handle_darwin(filename, targetfolder):
exe = "pandoc-citeproc"
src = os.path.join(pkgutilfolder, "usr", "local", "bin", exe)
dst = os.path.join(targetfolder, exe)
logger.info(f"Copying {exe} to {targetfolder} ...")
try:
if os.path.exists(src):
logger.info(f"Copying {exe} to {targetfolder} ...")
shutil.copyfile(src, dst)
_make_executable(dst)
except FileNotFoundError:
logger.exception("Didn't copy pandoc-citeproc")

# remove temporary dir
shutil.rmtree(tempfolder)
Expand All @@ -183,11 +179,9 @@ def _handle_win32(filename, targetfolder):
exe = "pandoc-citeproc.exe"
src = os.path.join(tempfolder, "Pandoc", exe)
dst = os.path.join(targetfolder, exe)
logger.info(f"Copying {exe} to {targetfolder} ...")
try:
if os.path.exists(src):
logger.info(f"Copying {exe} to {targetfolder} ...")
shutil.copyfile(src, dst)
except FileNotFoundError:
logger.exception("Didn't copy pandoc-citeproc.exe")

exe = "COPYRIGHT.txt"
src = os.path.join(tempfolder, "Pandoc", exe)
Expand Down

0 comments on commit 6aa5541

Please sign in to comment.