debug warnings are now also possible

This commit is contained in:
David Halter
2012-03-29 02:11:34 +02:00
parent 94e23958bb
commit 03a6bf6b59
2 changed files with 11 additions and 4 deletions

View File

@@ -7,6 +7,9 @@ def dbg(*args):
if not (mod.__name__ in ignored_modules): if not (mod.__name__ in ignored_modules):
debug_function(*args) debug_function(*args)
def warning(*args):
if debug_function:
debug_function(*args)
debug_function = None debug_function = None
ignored_modules = [] ignored_modules = []

View File

@@ -904,7 +904,7 @@ class PyFuzzyParser(object):
""" """
names = [] names = []
tok = None tok = None
while tok not in [')', '\n', ':']: while tok not in [')', ':']:
stmt, tok = self._parse_statement(added_breaks=',') stmt, tok = self._parse_statement(added_breaks=',')
if stmt: if stmt:
names.append(stmt) names.append(stmt)
@@ -1124,7 +1124,7 @@ class PyFuzzyParser(object):
while indent <= self.scope.indent \ while indent <= self.scope.indent \
and token_type in [tokenize.NAME] \ and token_type in [tokenize.NAME] \
and self.scope != self.top: and self.scope != self.top:
debug.dbg('syntax_err, dedent @%s - %s<=%s', \ debug.warning('syntax_err, dedent @%s - %s<=%s', \
(self.line_nr, indent, self.scope.indent)) (self.line_nr, indent, self.scope.indent))
self.scope.line_end = self.line_nr self.scope.line_end = self.line_nr
self.scope = self.scope.parent self.scope = self.scope.parent
@@ -1133,7 +1133,8 @@ class PyFuzzyParser(object):
if tok == 'def': if tok == 'def':
func = self._parsefunction(indent) func = self._parsefunction(indent)
if func is None: if func is None:
print "function: syntax error@%s" % self.line_nr debug.warning("function: syntax error@%s" %
self.line_nr)
continue continue
debug.dbg("new scope: function %s" % (func.name)) debug.dbg("new scope: function %s" % (func.name))
freshscope = True freshscope = True
@@ -1142,6 +1143,8 @@ class PyFuzzyParser(object):
elif tok == 'class': elif tok == 'class':
cls = self._parseclass(indent) cls = self._parseclass(indent)
if cls is None: if cls is None:
debug.warning("class: syntax error@%s" %
self.line_nr)
continue continue
freshscope = True freshscope = True
debug.dbg("new scope: class %s" % (cls.name)) debug.dbg("new scope: class %s" % (cls.name))
@@ -1158,7 +1161,8 @@ class PyFuzzyParser(object):
mod, token_type, tok, start_indent, start_line2 = \ mod, token_type, tok, start_indent, start_line2 = \
self._parsedotname() self._parsedotname()
if not mod or tok != "import": if not mod or tok != "import":
print "from: syntax error..." debug.warning("from: syntax error@%s" %
self.line_nr)
continue continue
mod = Name(mod, start_indent, start_line2, self.line_nr) mod = Name(mod, start_indent, start_line2, self.line_nr)
names = self._parseimportlist() names = self._parseimportlist()