pep8 formatting

This commit is contained in:
David Halter
2012-04-21 21:14:06 +02:00
parent 4feb8f5a3a
commit dccef451a2
5 changed files with 25 additions and 14 deletions

View File

@@ -54,7 +54,8 @@ class Parser(object):
self.sys_path.insert(0, self.path) self.sys_path.insert(0, self.path)
temp, sys.path = sys.path, self.sys_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 exec 'import %s as module' % self.name in self._content
self.sys_path, sys.path = sys.path, temp self.sys_path, sys.path = sys.path, temp
@@ -204,7 +205,7 @@ def parse_function_doc(func):
break break
param_str = doc[start + 1:end] 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): def change_options(m):
args = m.group(1).split(',') args = m.group(1).split(',')
for i, a in enumerate(args): for i, a in enumerate(args):

View File

@@ -4,6 +4,7 @@ NOTICE = object()
WARNING = object() WARNING = object()
ERROR = object() ERROR = object()
def dbg(*args): def dbg(*args):
if debug_function: if debug_function:
frm = inspect.stack()[1] frm = inspect.stack()[1]
@@ -11,19 +12,23 @@ def dbg(*args):
if not (mod.__name__ in ignored_modules): if not (mod.__name__ in ignored_modules):
debug_function(NOTICE, *args) debug_function(NOTICE, *args)
def warning(*args): def warning(*args):
if debug_function: if debug_function:
debug_function(WARNING, *args) debug_function(WARNING, *args)
def error(*args): def error(*args):
if debug_function: if debug_function:
debug_function(ERROR, *args) debug_function(ERROR, *args)
def print_to_stdout(level, *args): def print_to_stdout(level, *args):
""" The default debug function """ """ The default debug function """
print(('dbg: ' if level == NOTICE else 'warning: ') + print(('dbg: ' if level == NOTICE else 'warning: ') +
', '.join(str(a) for a in args)) ', '.join(str(a) for a in args))
debug_function = None debug_function = None
#debug_function = print_to_stdout #debug_function = print_to_stdout
ignored_modules = [] ignored_modules = []

View File

@@ -197,7 +197,8 @@ class Execution(Exec):
result.append(param.get_name()) result.append(param.get_name())
else: else:
new_param = copy.copy(param) 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] calls.values = [value]
new_param.assignment_calls = calls new_param.assignment_calls = calls
name = copy.copy(param.get_name()) name = copy.copy(param.get_name())
@@ -270,12 +271,11 @@ def get_scopes_for_name(scope, name, search_global=False):
# TODO get Flow data, which is defined by the loop # TODO get Flow data, which is defined by the loop
# (or with) # (or with)
pass pass
elif isinstance(par, parsing.Param): elif isinstance(par, parsing.Param) \
if isinstance(par.parent.parent, parsing.Class) \ and isinstance(par.parent.parent, parsing.Class) \
and par.position == 0: and par.position == 0:
# this is where self is added # this is where self gets added
result.append(Instance(par.parent.parent)) result.append(Instance(par.parent.parent))
else:
result.append(par) result.append(par)
else: else:
result.append(par) result.append(par)

View File

@@ -6,7 +6,8 @@ import evaluate
import modules import modules
import debug import debug
__all__ = ['complete', 'get_completion_parts', 'complete_test', 'set_debug_function'] __all__ = ['complete', 'get_completion_parts', 'set_debug_function']
class FileWithCursor(modules.File): class FileWithCursor(modules.File):
""" """
@@ -32,6 +33,7 @@ class FileWithCursor(modules.File):
def get_row_path(self, column): def get_row_path(self, column):
""" Get the path under the cursor. """ """ Get the path under the cursor. """
self._is_first = True self._is_first = True
def fetch_line(): def fetch_line():
line = self.get_line(self._row_temp) line = self.get_line(self._row_temp)
if self._is_first: if self._is_first:
@@ -159,6 +161,7 @@ def get_completion_parts(path):
match = re.match(r'^(.*?)(\.|)(\w?[\w\d]*)$', path, flags=re.S) match = re.match(r'^(.*?)(\.|)(\w?[\w\d]*)$', path, flags=re.S)
return match.groups() return match.groups()
def complete(source, row, column, source_path): def complete(source, row, column, source_path):
""" """
An auto completer for python files. An auto completer for python files.
@@ -211,5 +214,6 @@ def set_debug_function(func_cb):
""" """
debug.debug_function = func_cb debug.debug_function = func_cb
def _clear_caches(): def _clear_caches():
evaluate.clear_caches() evaluate.clear_caches()

View File

@@ -57,6 +57,7 @@ class File(object):
File.module_cache[self.module_path] = to_cache File.module_cache[self.module_path] = to_cache
return self._parser return self._parser
def find_module(current_module, point_path): def find_module(current_module, point_path):
""" """
Find a module with a path (of the module, like usb.backend.libusb10). Find a module with a path (of the module, like usb.backend.libusb10).