diff --git a/builtin.py b/builtin.py index 71210f2c..babd7ed0 100644 --- a/builtin.py +++ b/builtin.py @@ -54,7 +54,8 @@ class Parser(object): self.sys_path.insert(0, self.path) temp, sys.path = sys.path, self.sys_path - #print 'sypa', sys.path TODO reenable and check (stackoverflow ticket) + # TODO reenable and check (stackoverflow question - pylab builtins) + #print 'sypa', sys.path exec 'import %s as module' % self.name in self._content self.sys_path, sys.path = sys.path, temp @@ -204,7 +205,7 @@ def parse_function_doc(func): break param_str = doc[start + 1:end] - # remove square brackets, which show an optional param ( in Python = None) + # remove square brackets, that show an optional param ( = None) def change_options(m): args = m.group(1).split(',') for i, a in enumerate(args): diff --git a/debug.py b/debug.py index b3628f3f..4b96b592 100644 --- a/debug.py +++ b/debug.py @@ -4,26 +4,31 @@ NOTICE = object() WARNING = object() ERROR = object() + def dbg(*args): if debug_function: - frm = inspect.stack()[1] + frm = inspect.stack()[1] mod = inspect.getmodule(frm[0]) if not (mod.__name__ in ignored_modules): debug_function(NOTICE, *args) + def warning(*args): if debug_function: debug_function(WARNING, *args) + def error(*args): if debug_function: debug_function(ERROR, *args) + def print_to_stdout(level, *args): """ The default debug function """ print(('dbg: ' if level == NOTICE else 'warning: ') + ', '.join(str(a) for a in args)) + debug_function = None #debug_function = print_to_stdout ignored_modules = [] diff --git a/evaluate.py b/evaluate.py index 136f10ce..47a2ac18 100644 --- a/evaluate.py +++ b/evaluate.py @@ -189,15 +189,16 @@ class Execution(Exec): def get_params(self): result = [] for i, param in enumerate(self.base.params): - try: + try: value = self.params.values[i] except IndexError: # This means, that there is no param in the call. So we just - # ignore it and take the default params. + # ignore it and take the default params. result.append(param.get_name()) else: new_param = copy.copy(param) - calls = parsing.Array(parsing.Array.EMPTY, self.params.parent_stmt) + calls = parsing.Array(parsing.Array.EMPTY, + self.params.parent_stmt) calls.values = [value] new_param.assignment_calls = calls name = copy.copy(param.get_name()) @@ -270,13 +271,12 @@ def get_scopes_for_name(scope, name, search_global=False): # TODO get Flow data, which is defined by the loop # (or with) pass - elif isinstance(par, parsing.Param): - if isinstance(par.parent.parent, parsing.Class) \ - and par.position == 0: - # this is where self is added - result.append(Instance(par.parent.parent)) - else: - result.append(par) + elif isinstance(par, parsing.Param) \ + and isinstance(par.parent.parent, parsing.Class) \ + and par.position == 0: + # this is where self gets added + result.append(Instance(par.parent.parent)) + result.append(par) else: result.append(par) debug.dbg('sfn filter', result) diff --git a/functions.py b/functions.py index 91c425c9..26f2a42b 100644 --- a/functions.py +++ b/functions.py @@ -6,7 +6,8 @@ import evaluate import modules import debug -__all__ = ['complete', 'get_completion_parts', 'complete_test', 'set_debug_function'] +__all__ = ['complete', 'get_completion_parts', 'set_debug_function'] + class FileWithCursor(modules.File): """ @@ -32,6 +33,7 @@ class FileWithCursor(modules.File): def get_row_path(self, column): """ Get the path under the cursor. """ self._is_first = True + def fetch_line(): line = self.get_line(self._row_temp) if self._is_first: @@ -159,6 +161,7 @@ def get_completion_parts(path): match = re.match(r'^(.*?)(\.|)(\w?[\w\d]*)$', path, flags=re.S) return match.groups() + def complete(source, row, column, source_path): """ An auto completer for python files. @@ -211,5 +214,6 @@ def set_debug_function(func_cb): """ debug.debug_function = func_cb + def _clear_caches(): evaluate.clear_caches() diff --git a/modules.py b/modules.py index 2a9a91f1..62338e2b 100644 --- a/modules.py +++ b/modules.py @@ -57,6 +57,7 @@ class File(object): File.module_cache[self.module_path] = to_cache return self._parser + def find_module(current_module, point_path): """ Find a module with a path (of the module, like usb.backend.libusb10).