diff --git a/dynamic.py b/dynamic.py index 81c95737..1f958c49 100644 --- a/dynamic.py +++ b/dynamic.py @@ -55,7 +55,7 @@ def search_params(param): for params in listener.param_possibilities: for p in params: if str(p) == param_name: - result += evaluate.follow_statement(p.parent) + result += evaluate.follow_statement(p.parent()) #print listener.param_possibilities, param, result return result @@ -63,8 +63,8 @@ def search_params(param): func = param.get_parent_until(parsing.Function) current_module = param.get_parent_until() func_name = str(func.name) - if func_name == '__init__' and isinstance(func.parent, parsing.Class): - func_name = str(func.parent.name) + if func_name == '__init__' and isinstance(func.parent(), parsing.Class): + func_name = str(func.parent().name) # get the param name if param.assignment_details: @@ -125,7 +125,7 @@ def _check_array_additions(compare_array, module, is_list): backtrack_path = iter(call_path[:separate_index]) position = c.parent_stmt.start_pos - scope = c.parent_stmt.parent + scope = c.parent_stmt.parent() e = evaluate.follow_call_path(backtrack_path, scope, position) if not compare_array in e: # the `append`, etc. belong to other arrays diff --git a/evaluate.py b/evaluate.py index 2854b35c..7c2d7dee 100644 --- a/evaluate.py +++ b/evaluate.py @@ -946,6 +946,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False): and scope.var == name.parent().parent(): name = InstanceElement(scope.instance, name) par = name.parent() + print name, par if par.isinstance(parsing.Flow): if par.command == 'for': result += handle_for_loops(par) diff --git a/imports.py b/imports.py index a9ef4b96..062a5f46 100644 --- a/imports.py +++ b/imports.py @@ -61,7 +61,7 @@ class ImportPath(object): zero = (None, None) n = parsing.Name(i.namespace.names[1:], zero, zero) new = parsing.Import(zero, zero, n) - new.parent = parent + new.parent = lambda: parent debug.dbg('Generated a nested import: %s' % new) return new diff --git a/parsing.py b/parsing.py index 871e6db3..a33c629d 100644 --- a/parsing.py +++ b/parsing.py @@ -110,7 +110,6 @@ class Scope(Simple): self.docstr = docstr def add_scope(self, sub, decorators): - print 'push scope @%s,%s' % sub.start_pos sub.parent = weakref.ref(self) sub.decorators = decorators for d in decorators: @@ -460,7 +459,6 @@ class Flow(Scope): else: self.next = next self.next.parent = self.parent - print 'n', self.next #next.top_flow = self.top_flow return next @@ -1349,8 +1347,8 @@ class PyFuzzyParser(object): token_type, tok = self.next() #debug.dbg('main: tok=[%s] type=[%s] indent=[%s]'\ # % (tok, token_type, start_position[0])) - print('main: tok=[%s] type=[%s] indent=[%s]' - % (tok, tokenize.tok_name[token_type], self.start_pos[0])) + #print('main: tok=[%s] type=[%s] indent=[%s]' + # % (tok, tokenize.tok_name[token_type], self.start_pos[0])) while token_type == tokenize.DEDENT \ and self.scope != self.module: