Eric Raymond:

Add a convenience function to generate C-compiler style error leaders.
This commit is contained in:
Guido van Rossum 2000-05-01 20:14:12 +00:00
parent eb4e11ae44
commit 4b83ecbbaa
1 changed files with 8 additions and 0 deletions

View File

@ -158,6 +158,14 @@ class shlex:
newfile = newfile[1:-1] newfile = newfile[1:-1]
return (newfile, open(newfile, "r")) 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__': if __name__ == '__main__':
lexer = shlex() lexer = shlex()