Skip to content

Commit

Permalink
Script: clean-up some code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rbeezer committed Jan 17, 2024
1 parent 0ed263f commit 1ad9112
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions pretext/pretext.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
# vermin is a great linter/checker to check versions required
# https://github.com/netromdk/vermin.git
# 2023-10-13: this module expects Python 3.8 or newer
# shutil.copytree now has dirs_exist_ok argument
# 2021-05-21: this module expects Python 3.6 or newer
# copying HTML into cwd twice, might be better with
# shutil.copytree(dirs_exist_ok), requires Python 3.8
# see comments near copytree() and copy_tree()
#
# subprocess.run() requires Python 3.5
# shutil.which() member requires 3.3
Expand Down Expand Up @@ -73,7 +71,7 @@
import os.path

# primarily copying entire directory trees of files, also which()
# TODO: copy() vs copy2() vs copyfile() vs copyfileobj()?
# we limit ourselves to shutil.copy2 and shutil.copytree
# Study: https://www.techbeamers.com/python-copy-file/
import shutil

Expand Down Expand Up @@ -316,8 +314,8 @@ def asymptote_conversion(
# setup, depending on the method
if method == "local":
asy_executable_cmd = get_executable_cmd("asy")
# perhaps replace following stock advisory with a real version
# check using the (undocumented) distutils.version module, see:
# perhaps replace following stock advisory
# with a real version check. Perhaps see:
# https://stackoverflow.com/questions/11887762/how-do-i-compare-version-numbers-in-python
proc = subprocess.Popen(
[asy_executable_cmd[0], "--version"], stderr=subprocess.PIPE
Expand Down Expand Up @@ -468,7 +466,6 @@ def latex_image_conversion(
# Need to copy entire external directory in the managed case.
# Making data files available for latex image compilation is
# not supported outside of the managed directory scheme (2021-07-28)
# copytree() does not overwrite since tmp_dir is created anew on each use
_, external_dir = get_managed_directories(xml_source, pub_file)
copy_managed_directories(tmp_dir, external_abs=external_dir)
# now create all the standalone LaTeX source files
Expand Down Expand Up @@ -862,7 +859,6 @@ def latex_tactile_image_conversion(
# Need to copy entire external directory in the managed case.
# Making data files available for latex image compilation is
# not supported outside of the managed directory scheme (2021-07-28)
# copytree() does not overwrite since tmp_dir is created anew on each use
_, external_dir = get_managed_directories(xml_source, pub_file)
copy_managed_directories(tmp_dir, external_abs=external_dir)
# now create all the standalone LaTeX source files
Expand Down Expand Up @@ -3442,8 +3438,6 @@ def pdf(xml, pub_file, stringparams, extra_xsl, out_file, dest_dir, method):
# (2) pass tmp_dir (scratch) as destination directory
latex(xml, pub_file, stringparams, extra_xsl, None, tmp_dir)

# "dirs_exist_ok" keyword is Python 3.8; necessary?

# Create localized filenames for pdflatex conversion step
# sourcename needs to match behavior of latex() with above arguments
basename = os.path.splitext(os.path.split(xml)[1])[0]
Expand Down Expand Up @@ -4081,7 +4075,7 @@ def copy_managed_directories(build_dir, external_abs=None, generated_abs=None):
# Copies external and generated directories from absolute paths set in external_abs
# and generated_abs (unless set to None) into a build directory. Since the
# build directory is fresh for each build, these directories should not exist
# in advance and the copytree() function should raise an error.
# in advance and the shutil.copytree() function should raise an error.
if external_abs is not None:
external_dir = os.path.join(build_dir, "external")
shutil.copytree(external_abs, external_dir)
Expand Down

0 comments on commit 1ad9112

Please sign in to comment.