aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtexall51
1 files changed, 48 insertions, 3 deletions
diff --git a/texall b/texall
index 82516ce..caa6269 100755
--- a/texall
+++ b/texall
@@ -78,7 +78,48 @@ if os.path.exists("/dev/null"):
null = file("/dev/null", "wb")
else:
null = file("nul:", "wb")
+
+# platform checking:
+iswindows = (sys.platform == "win32")
+
+# provide a copy of os.path.relpath from python 2.6
+if not iswindows:
+ def relpath(path, start=os.path.curdir):
+ """Return a relative version of a path"""
+
+ start_list = os.path.abspath(start).split(os.path.sep)
+ path_list = os.path.abspath(path).split(os.path.sep)
+ # Work out how much of the filepath is shared by start and path.
+ i = len(os.path.commonprefix([start_list, path_list]))
+
+ rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
+ return os.path.join(*rel_list)
+else:
+ def relpath(path, start=os.path.curdir):
+ """Return a relative version of a path"""
+
+ start_list = os.path.abspath(start).split(os.path.sep)
+ path_list = os.path.abspath(path).split(os.path.sep)
+ if start_list[0].lower() != path_list[0].lower():
+ unc_path, rest = os.path.splitunc(path)
+ unc_start, rest = os.path.splitunc(start)
+ if bool(unc_path) ^ bool(unc_start):
+ raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)"
+ % (path, start))
+ else:
+ raise ValueError("path is on drive %s, start on drive %s"
+ % (path_list[0], start_list[0]))
+ # Work out how much of the filepath is shared by start and path.
+ for i in range(min(len(start_list), len(path_list))):
+ if start_list[i].lower() != path_list[i].lower():
+ break
+ else:
+ i += 1
+
+ rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
+ return os.path.join(*rel_list)
+
path = os.path.expandvars("$PATH")
if path == "$PATH":
path = os.path.defpath
@@ -426,7 +467,11 @@ def run(arglist, dirname, reason="", inf=None, outf=None, stderr=None):
stderr -- file to be used as stderr
"""
if options.verbosity:
- print " running %s%s..."%(" ".join(arglist), reason)
+ redir =""
+ if hasattr(inf, "name") and inf.name != "" and inf.name[0] != "<":
+ name = relpath(inf.name, dirname)
+ redir = " < %s"%name
+ print " running %s%s%s..."%(" ".join(arglist), redir, reason)
if options.act:
master, slave = None, None
@@ -434,7 +479,7 @@ def run(arglist, dirname, reason="", inf=None, outf=None, stderr=None):
if isinstance(inf, file):
stdin = inf
inf = None
- elif options.showoutput and not subprocess.mswindows:
+ elif options.showoutput and not iswindows:
master, slave = pty.openpty()
master = os.fdopen(master, "rw")
stdin=slave
@@ -446,7 +491,7 @@ def run(arglist, dirname, reason="", inf=None, outf=None, stderr=None):
if isinstance(outf, file):
stdout = outf
outf = None
- elif options.showoutput and not subprocess.mswindows:
+ elif options.showoutput and not iswindows:
if slave == None:
master, slave = pty.openpty()
master = os.fdopen(master, "rw")