summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-05-01 20:14:12 (GMT)
committerGuido van Rossum <guido@python.org>2000-05-01 20:14:12 (GMT)
commit4b83ecbbaa413f5459098d4a011cf4bed685b06b (patch)
tree0363f8d536ebcd1e7cea13858dad4084d1b9e7b6
parenteb4e11ae44c48bde77405584e8834d3ace57144b (diff)
downloadcpython-4b83ecbbaa413f5459098d4a011cf4bed685b06b.zip
cpython-4b83ecbbaa413f5459098d4a011cf4bed685b06b.tar.gz
cpython-4b83ecbbaa413f5459098d4a011cf4bed685b06b.tar.bz2
Eric Raymond:
Add a convenience function to generate C-compiler style error leaders.
-rw-r--r--Lib/shlex.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/shlex.py b/Lib/shlex.py
index 95d08d2..575fc35 100644
--- a/Lib/shlex.py
+++ b/Lib/shlex.py
@@ -158,6 +158,14 @@ class shlex:
newfile = newfile[1:-1]
return (newfile, open(newfile, "r"))
+ def error_leader(self, infile=None, lineno=None):
+ "Emit a C-compiler-like, Emacs-friendly error-message leader."
+ if not infile:
+ infile = self.infile
+ if not lineno:
+ lineno = self.lineno
+ return "\"%s\", line %d: " % (infile, lineno)
+
if __name__ == '__main__':
lexer = shlex()