[kernel-team] 26/86: lib/kconfigeditor/kconfig/menu/file.py: Provide proper exception.
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Mon Dec 21 00:34:55 UTC 2015
This is an automated email from the git hooks/post-receive script.
benh pushed a commit to branch benh/kconfigeditor2
in repository kernel-team.
commit 3eea708a6b466a3bfc66f9cf636e1aa2e3cfabe5
Author: Bastian Blank <waldi at debian.org>
Date: Thu Mar 13 11:22:25 2008 +0000
lib/kconfigeditor/kconfig/menu/file.py: Provide proper exception.
svn path=/people/waldi/utils/kconfigeditor2/; revision=10829
---
.../lib/kconfigeditor/kconfig/menu/file.py | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py b/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py
index 084099c..bffd931 100644
--- a/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py
+++ b/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py
@@ -1,5 +1,15 @@
import re
+class ParseException(Exception):
+ filename = None
+ lineno = None
+
+ def __init__(self, text):
+ self.text = text
+
+ def __str__(self):
+ return "%s:%d: %s" % (self.filename, self.lineno, self.text)
+
class File(list):
def __init__(self, filename):
self.filename = filename
@@ -41,8 +51,10 @@ class Parser(object):
else:
try:
stack.top().process_line(line)
- except Exception, e:
- raise Exception("Can't parse: '%s' (%d): %s" % (line, lineno, e))
+ except ParseException, e:
+ e.filename = filename
+ e.lineno = lineno
+ raise
lineno += 1
return stack.top().process_stop(lineno, 0)
@@ -121,7 +133,7 @@ $"""
def process_line(self, text):
match = self.split_re.match(text)
if not match:
- raise Exception, "Can't parse: '%s'" % text
+ raise ParseException("No match")
rest = match.group('rest1') or match.group('rest2')
getattr(self, "process_%s" % match.group('word'))(rest, match.group('ind'))
@@ -224,7 +236,7 @@ $"""
self.entry.prompt = match.group('text1') or match.group('text2')
text = match.group('expression')
else:
- raise Exception
+ raise ParseException("Can't find a prompt")
_Expression(self, text)
def process_bool(self, text, ind):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/kernel-team.git
More information about the Kernel-svn-changes
mailing list