]> granicus.if.org Git - python/commitdiff
Eric Raymond:
authorGuido van Rossum <guido@python.org>
Mon, 1 May 2000 20:14:12 +0000 (20:14 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 1 May 2000 20:14:12 +0000 (20:14 +0000)
Add a convenience function to generate C-compiler style error leaders.

Lib/shlex.py

index 95d08d281b2aa3a353cdcac654edc8c92eaa851b..575fc35ee639d11ec89d437167fd0b643a2289c3 100644 (file)
@@ -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()