summaryrefslogtreecommitdiffstats
path: root/Doc/tools/mkhowto
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-06-23 03:06:01 (GMT)
committerFred Drake <fdrake@acm.org>2001-06-23 03:06:01 (GMT)
commitbfd80dd8c01a27f7ce1eb7a24ef9982e024a00e4 (patch)
treea106fb8ded14d589803bec1a25db361b119826c8 /Doc/tools/mkhowto
parent95c80f84392e6fb2a023542a0a4a50dfe3298cc2 (diff)
downloadcpython-bfd80dd8c01a27f7ce1eb7a24ef9982e024a00e4.zip
cpython-bfd80dd8c01a27f7ce1eb7a24ef9982e024a00e4.tar.gz
cpython-bfd80dd8c01a27f7ce1eb7a24ef9982e024a00e4.tar.bz2
Miscellaneous code cleanups.
Make sure we do not lose track of the build directory -- convert a user- supplied directory to an absolute path.
Diffstat (limited to 'Doc/tools/mkhowto')
-rwxr-xr-xDoc/tools/mkhowto14
1 files changed, 10 insertions, 4 deletions
diff --git a/Doc/tools/mkhowto b/Doc/tools/mkhowto
index f92cbda..5b69fe3 100755
--- a/Doc/tools/mkhowto
+++ b/Doc/tools/mkhowto
@@ -47,6 +47,7 @@ import tempfile
if not hasattr(os.path, "abspath"):
+ # Python 1.5.1 or earlier
def abspath(path):
"""Return an absolute path."""
if not os.path.isabs(path):
@@ -214,6 +215,8 @@ class Options:
os.path.join(TOPDIR, "paper-" + self.paper),
os.path.join(TOPDIR, "texinputs"),
] + texinputs
+ if self.builddir:
+ self.builddir = os.path.abspath(self.builddir)
class Job:
@@ -223,7 +226,10 @@ class Job:
self.options = options
self.doctype = get_doctype(path)
self.filedir, self.doc = split_pathname(path)
- self.log_filename = self.doc + ".how"
+ self.builddir = os.path.abspath(options.builddir or self.doc)
+ if not os.path.exists(self.builddir):
+ os.mkdir(self.builddir)
+ self.log_filename = os.path.join(self.builddir, self.doc + ".how")
if os.path.exists(self.log_filename):
os.unlink(self.log_filename)
if os.path.exists(self.doc + ".l2h"):
@@ -243,7 +249,7 @@ class Job:
self.build_ps()
if "html" in formats:
self.require_temps()
- self.build_html(self.options.builddir or self.doc)
+ self.build_html(self.builddir)
if self.options.icon_server == ".":
pattern = os.path.join(TOPDIR, "html", "icons",
"*." + self.options.image_type)
@@ -346,7 +352,7 @@ class Job:
def build_html(self, builddir=None, max_split_depth=None):
if builddir is None:
- builddir = self.doc
+ builddir = self.builddir
if max_split_depth is None:
max_split_depth = self.options.max_split_depth
texfile = None
@@ -520,7 +526,7 @@ def safe_unlink(path):
def split_pathname(path):
- path = os.path.normpath(os.path.join(os.getcwd(), path))
+ path = os.path.abspath(path)
dirname, basename = os.path.split(path)
if basename[-4:] == ".tex":
basename = basename[:-4]