Commits

Henning Schröder committed 161b067

pep8

Comments (0)

Files changed (169)

 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys, os
+import sys
+import os
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #sys.path.insert(0, os.path.abspath('.'))
 
-# -- General configuration -----------------------------------------------------
+# -- General configuration -----------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.
 #needs_sphinx = '1.0'
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 
-              'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.viewcode']
+extensions = [
+    'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx',
+    'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.viewcode']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 #modindex_common_prefix = []
 
 
-# -- Options for HTML output ---------------------------------------------------
+# -- Options for HTML output ---------------------------------------------
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
 htmlhelp_basename = 'PyCodedoc'
 
 
-# -- Options for LaTeX output --------------------------------------------------
+# -- Options for LaTeX output --------------------------------------------
 
 latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-#'papersize': 'letterpaper',
+    # The paper size ('letterpaper' or 'a4paper').
+    #'papersize': 'letterpaper',
 
-# The font size ('10pt', '11pt' or '12pt').
-#'pointsize': '10pt',
+    # The font size ('10pt', '11pt' or '12pt').
+    #'pointsize': '10pt',
 
-# Additional stuff for the LaTeX preamble.
-#'preamble': '',
+    # Additional stuff for the LaTeX preamble.
+    #'preamble': '',
 }
 
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-  ('index', 'PyCode.tex', u'PyCode Documentation',
-   u'Henning Schröder', 'manual'),
+    ('index', 'PyCode.tex', u'PyCode Documentation',
+     u'Henning Schröder', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
 #latex_domain_indices = True
 
 
-# -- Options for manual page output --------------------------------------------
+# -- Options for manual page output --------------------------------------
 
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 #man_show_urls = False
 
 
-# -- Options for Texinfo output ------------------------------------------------
+# -- Options for Texinfo output ------------------------------------------
 
 # Grouping the document tree into Texinfo files. List of tuples
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-  ('index', 'PyCode', u'PyCode Documentation',
-   u'Henning Schröder', 'PyCode', 'One line description of project.',
-   'Miscellaneous'),
+    ('index', 'PyCode', u'PyCode Documentation',
+     u'Henning Schröder', 'PyCode', 'One line description of project.',
+     'Miscellaneous'),
 ]
 
 # Documents to append as an appendix to all manuals.
 from threading import Thread
 
 
-
 class Server(object):
-    
 
     def __init__(self):
         pass
 
-    
     def received(self, data):
         print "received", len(data), "bytes"
         return data
 
 
-
 class Connection(object):
 
-
     def __init__(self, server_factory):
         self.server_factory = server_factory
         self.input_queue = Queue()
         self.output_queue = Queue()
 
-
     def _listen(self, server_factory, input_queue, output_queue):
         server = server_factory()
         while True:
             result = server.received(item)
             output_queue.put(result)
 
-        
     def start(self):
-        self.proc = Process(target=self._listen, args=(self.server_factory, self.input_queue, self.output_queue))
+        self.proc = Process(target=self._listen, args=(
+            self.server_factory, self.input_queue, self.output_queue))
         self.proc.start()
 
 
+class Client(object):
 
-
-class Client(object):
-    
-    
     def __init__(self, connection):
         self._connection = connection
         atexit.register(self._exit)
         self._callback_thread = Thread(target=self._watch_results)
         self._callback_thread.setDaemon(True)
         self._callback_thread.start()
-        
 
     def _exit(self):
         self._call(None, None)
 
-
     def _watch_results(self):
         while True:
             item = self._connection.output_queue.get()
                 break
             callback = self._callback_queue.pop()
             callback(item)
-        
-        
-    def _call(self, data, callback):    
+
+    def _call(self, data, callback):
         self._connection.input_queue.put(data)
         self._callback_queue.insert(0, callback)
 
-
     def call(self, data, callback):
         self._call(data, callback)
 
-        
-        
+
 class IpcCallMixIn(object):
 
-    
     def _decode_call(self, data):
         (msg, args, kwargs) = data
         return (msg, args, kwargs)
-    
-    
+
     def _encode_result(self, error, result):
         return (error, result)
-    
 
     def _encode_call(self, msg, args, kwargs):
         info = (msg, args, kwargs)
         data = info
         return data
 
-        
     def _decode_result(self, data):
         error, value = data
         if error:
         return value
 
 
-    
 class IpcServer(Server, IpcCallMixIn):
 
-
     def __init__(self, root=None):
         Server.__init__(self)
         if root is None:
             root = self
         self._root = root
 
-
     def received(self, data):
         msg, args, kwargs = self._decode_call(data)
         method = getattr(self._root, msg)
         return self._encode_result(error, result)
 
 
-
-
 class _ResultCallback(object):
 
-    
     def __init__(self, client, callback):
         self.client = client
         self.callback = callback
-        
 
     def __call__(self, data):
         result = self.client._decode_result(data)
         return self.callback(result)
 
-        
-        
+
 class IpcClient(Client, IpcCallMixIn):
-    
 
     def call(self, msg, *args, **kwargs):
         callback = kwargs.pop("callback")
         data = self._encode_call(msg, args, kwargs)
         return self._call(data, callback=_ResultCallback(self, callback))
 
-    
     def __getattr__(self, name):
         method = lambda *args, **kwargs: self.call(name, *args, **kwargs)
         return method
 
 
-
 if __name__ == "__main__":
     def cb(result):
         print "got", repr(result)
 
     def create_server():
         class Root(object):
+
             def foo(self):
                 return "Foo!"
+
             def bar(self, count=1):
                 return "BAR" * count
         server = IpcServer(Root())
     client = IpcClient(con)
     client.foo(callback=cb)
     client.bar(2, callback=cb)
-    
-    import time; time.sleep(1)
-    print "done"
+
+    import time
+    time.sleep(1)
+    print "done"
 PACKET_SIZE = 8192
 
 
-
 class NetworkError (exceptions.StandardError):
     pass
 
     pass
 
 
-
 class AsyncServerChannel(asynchat.async_chat):
 
     STATE_LENGTH = State()
     STATE_PACKET = State()
 
-
-    def __init__ (self, conn, addr, callback):
+    def __init__(self, conn, addr, callback):
         self.addr = addr
-        asynchat.async_chat.__init__ (self, conn)
+        asynchat.async_chat.__init__(self, conn)
         self.pstate = self.STATE_LENGTH
         self.set_terminator(8)
         self._receive_buffer = []
         self.callback = callback
 
-
-    def log (self, *items):
+    def log(self, *items):
         print "log", self.__class__, items
 
+    def collect_incoming_data(self, data):
+        self._receive_buffer.append(data)
 
-    def collect_incoming_data (self, data):
-        self._receive_buffer.append (data)
-
-
-    def found_terminator (self):
+    def found_terminator(self):
         self._receive_buffer, data = [], ''.join(self._receive_buffer)
 
         if self.pstate is self.STATE_LENGTH:
             self.set_terminator(packet_length)
             self.pstate = self.STATE_PACKET
         else:
-            self.set_terminator (8)
+            self.set_terminator(8)
             self.pstate = self.STATE_LENGTH
 
             result = self.callback(self.addr, data) or ""
-            
+
             self.push(('%08x' % len(result)) + result)
 
 
-
 class AsyncServer(asyncore.dispatcher):
 
-    
-    def __init__ (self, listen_addres=('', DEFAULT_PORT), handler_factory=AsyncServerChannel):
+    def __init__(self, listen_addres=('', DEFAULT_PORT), handler_factory=AsyncServerChannel):
         asyncore.dispatcher.__init__(self)
         self._handler_factory = handler_factory
-        self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
+        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
         self.set_reuse_addr()
         self.bind(listen_addres)
-        self.listen(128) 
+        self.listen(128)
 
-
-    def handle_accept (self):
+    def handle_accept(self):
         conn, addr = self.accept()
         print "Got connect", conn, addr
         self._handler_factory(conn, addr, self.on_received)
 
-
     def on_received(self, addr, data):
         return ''
 
 
-
-    
-        
-
 class AsyncClient(asynchat.async_chat):
 
     STATE_LENGTH = State()
     STATE_PACKET = State()
 
-
-    def __init__ (self, address=('', DEFAULT_PORT), keep_alive=False):
+    def __init__(self, address=('', DEFAULT_PORT), keep_alive=False):
 
         asynchat.async_chat.__init__(self)
 
         else:
             family = socket.AF_INET
 
-        self.create_socket (family, socket.SOCK_STREAM)
+        self.create_socket(family, socket.SOCK_STREAM)
         self._address = address
         self._request_fifo = []
         self._receive_buffer = []
         self._pstate = self.STATE_LENGTH
-        self.set_terminator (8)
+        self.set_terminator(8)
         self._connected = False
         self._keep_alive = keep_alive
-        self.connect (self._address)
+        self.connect(self._address)
 
-
-    def log (self, *items):
+    def log(self, *items):
         print "log ", self.__class__, items
 
-
-    def handle_connect (self):
+    def handle_connect(self):
         self._connected = True
 
-
     def close(self):
         self._connected = False
-        self.flush_pending_requests ('lost connection to rpc server')
+        self.flush_pending_requests('lost connection to rpc server')
         asynchat.async_chat.close(self)
 
-        
-    def flush_pending_requests (self, why):
+    def flush_pending_requests(self, why):
         f = self._request_fifo
         while len(f):
             callback = f.pop(0)
-            callback (why, None)
+            callback(why, None)
 
+    def collect_incoming_data(self, data):
+        print "incoming", len(data)
+        self._receive_buffer.append(data)
 
-    def collect_incoming_data (self, data):
-        print "incoming", len(data)
-        self._receive_buffer.append (data)
-
-
-    def found_terminator (self):
-        self._receive_buffer, data = [], ''.join (self._receive_buffer)
+    def found_terminator(self):
+        self._receive_buffer, data = [], ''.join(self._receive_buffer)
 
         if self._pstate is self.STATE_LENGTH:
             packet_length = int(data, 16)
             self._pstate = self.STATE_PACKET
         else:
             if self._keep_alive:
-                self.set_terminator (8)
+                self.set_terminator(8)
                 self._pstate = self.STATE_LENGTH
             callback = self._request_fifo.pop(0)
             callback(data)
             if not self._keep_alive:
                 self.close()
 
-
     def call(self, packet, callback):
         if not self._connected:
             # might be a unix socket...
             family, type = self.family_and_type
             self.create_socket(family, type)
-            self.connect (self._address)
+            self.connect(self._address)
         # push the request out the socket
-        self.push ('%08x%s' % (len(packet), packet))
+        self.push('%08x%s' % (len(packet), packet))
         self._request_fifo.append(callback)
 
 
-
-
 class Client(object):
 
-
-    def __init__ (self, address, keep_alive=True):
+    def __init__(self, address, keep_alive=True):
         self._address = address
         self._socket = None
         self._keep_alive = keep_alive
 
-
     def connect(self):
-        s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
+        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         s.connect(self._address)
         self._socket = s
 
-
     def receive_packet(self):
         s = self._socket.recv(8)
         if len(s) != 8:
         packet = []
         while packet_len:
             data = self._socket.recv(PACKET_SIZE)
-            packet.append (data)
+            packet.append(data)
             packet_len = packet_len - len(data)
         return ''.join(packet)
 
-
-    def send_packet (self, packet):
+    def send_packet(self, packet):
         self._socket.send('%08x%s' % (len(packet), packet))
 
-    
     def call(self, data):
         if self._socket is None:
             self.connect()
         return result
 
 
-    
 class RpcCallMixIn(object):
 
-    
     def _decode_call(self, data):
         (msg, args, kwargs) = pickle.loads(data)
         return (msg, args, kwargs)
-    
-    
+
     def _encode_result(self, error, result):
         return pickle.dumps((error, result), 2)
-    
 
     def _encode_call(self, msg, args, kwargs):
         info = (msg, args, kwargs)
         data = pickle.dumps(info, 2)
         return data
 
-        
     def _decode_result(self, data):
         error, value = pickle.loads(data)
         if error:
         return value
 
 
-    
 class RpcServer(AsyncServer, RpcCallMixIn):
 
-
-    def __init__ (self, root=None, listen_address=('', DEFAULT_PORT), handler_factory=AsyncServerChannel):
+    def __init__(self, root=None, listen_address=('', DEFAULT_PORT), handler_factory=AsyncServerChannel):
         if root is None:
             root = self
         self._root = root
         AsyncServer.__init__(self, listen_address, handler_factory)
 
-    
     def call(self, name, *args, **kwargs):
         method = getattr(self._root, name)
         return method(*args, **kwargs)
 
-
     def on_received(self, addr, data):
         (msg, args, kwargs) = self._decode_call(data)
         try:
             error = exc
             result = None
         return self._encode_result(error, result)
-    
-
-
 
 
 class RpcClient(Client, RpcCallMixIn):
 
-
     def call(self, msg, *args, **kwargs):
         send_data = self._encode_call(msg, args, kwargs)
         receive_data = super(RpcClient, self).call(send_data)
         return self._decode_result(receive_data)
 
-    
     def __getattr__(self, name):
         wrapper = lambda *args, **kwargs: self.call(name, *args, **kwargs)
         return wrapper
 
-    
-    
+
 class _ResultCallback(object):
 
-    
     def __init__(self, client, callback):
         self.client = client
         self.callback = callback
-        
 
     def __call__(self, data):
         result = self.client._decode_result(data)
         return self.callback(result)
 
 
-
 class AsyncRpcClient(AsyncClient, RpcCallMixIn):
-    
 
     def call(self, msg, *args, **kwargs):
         callback = kwargs.pop("callback")
         packet = self._encode_call(msg, args, kwargs)
-        AsyncClient.call(self, packet, callback=_ResultCallback(self, callback))
+        AsyncClient.call(
+            self, packet, callback=_ResultCallback(self, callback))
 
-
-    
     def __getattr__(self, name):
         wrapper = lambda *args, **kwargs: self.call(name, *args, **kwargs)
         return wrapper
 
 
-
-
 def async_event_loop():
     asyncore.loop()
 
 
-
 if __name__ == "__main__":
     def client():
         def cb(result):
         c.error("Error!", callback=cb)
         async_event_loop()
 
-
     def server():
         class Service(object):
+
             def echo(self, val):
                 return val
+
             def twice(self, val):
                 return val * 2
+
             def error(self, msg):
                 raise Exception(msg)
         address = ('', DEFAULT_PORT)
         print "Server running at", address
         async_event_loop()
 
-
     if "-s" in sys.argv:
         server()
     else:
         client()
-

lab/ctokenize/setup.py

 from Cython.Distutils import build_ext
 
 if __name__ == "__main__":
-    setup(name = "tokenize",
-      version = "2.7",
-      description = "Python module for tokenizing source",
-      cmdclass = {'build_ext': build_ext},
-      ext_modules = [ 
-          Extension("tokenize", ["tokenize.pyx"])
-      ]
-    )
+    setup(name="tokenize",
+          version="2.7",
+          description="Python module for tokenizing source",
+          cmdclass={'build_ext': build_ext},
+          ext_modules=[
+              Extension("tokenize", ["tokenize.pyx"])
+          ]
+          )
         self.out = []
         self.indent = " " * 4
 
+    def emit(self, code, depth=0):
+        self.out.append("%s%s" % (self.indent * depth, code))
 
-    def emit(self, code, depth=0):
-        self.out.append("%s%s" % (self.indent*depth, code))
-
-        
     def emit_doc(self, doc, depth):
         if doc:
             if "\n" in doc:
-                doc = "\n".join(self.indent + l for l in doc.splitlines())[len(self.indent):]
+                doc = "\n".join(self.indent + l for l in doc.splitlines())[
+                    len(self.indent):]
                 self.emit("'''%s'''" % doc, depth)
             else:
                 self.emit(pformat(doc), depth)
             self.emit("")
 
-        
     def __str__(self):
         return "\n".join(self.out)
 
-
     def create_stub(self, root, depth=0):
         doc = getattr(root, "__doc__")
         if doc:
                 elif isclass(value):
                     self.create_class_stub(name, value, depth)
             else:
-                pass #print "*", name, type(value), callable(value)
+                pass  # print "*", name, type(value), callable(value)
 
-            
     def create_class_stub(self, name, cls, depth):
         self.emit("")
         if cls.__name__ != name:
             bases = cls.__bases__
             if bases:
                 bases = "(%s)" % ", ".join(b.__name__ for b in bases)
-            self.emit("class %s%s:" % (name, bases))                
-            if not self.create_stub(cls, depth+1):
-                self.emit("pass", depth+1)
-
+            self.emit("class %s%s:" % (name, bases))
+            if not self.create_stub(cls, depth + 1):
+                self.emit("pass", depth + 1)
 
     def func_args(self, func):
         try:
             args, varargs, keywords, defaults = getargspec(func)
             defaults = dict(zip(args[-len(defaults):], defaults))
             if varargs:
-                args.append("*"+varargs)
+                args.append("*" + varargs)
             for i, a in enumerate(args):
                 try:
                     d = defaults[a]
                 return "self, " + args.split("(", 1)[1].rsplit(")", 1)[0]
             return "*args"
 
-                
     def create_function_stub(self, name, func, depth):
         self.emit("")
         if func.__name__ != name:
-            self.emit("%s = %s # function alias" % (name, func.__name__), depth)
+            self.emit("%s = %s # function alias" %
+                      (name, func.__name__), depth)
         else:
             args = self.func_args(func)
             self.emit("def %s(%s):" % (name, args), depth)
             doc = getattr(func, "__doc__", "")
             if doc:
-                self.emit_doc(doc, depth+1)
+                self.emit_doc(doc, depth + 1)
             else:
-                self.emit("pass", depth+1)
+                self.emit("pass", depth + 1)
                 self.emit("")
         self.emit("")
 
-        
     def create_stub_from_module(self, module_name):
         mod = __import__(module_name, {}, {}, [])
         for part in module_name.split(".")[1:]:
         if doc:
             self.emit_doc(doc)
         self.create_stub(mod)
-        
-    
+
+
 c = StubCreator()
 c.create_stub_from_module("PyQt4.QtGui")
-print c
+print c

lab/simple-python-checker.py

 import os
 import ast
 
+
 class GreenYellowRedLimit:
+
     """ this class handles three ranges: green, yellow and red.
         <ul>
             <li><b>green</b>:  indicates that a value is valid
                                An error message will be generated.
         </ul>
     """
+
     def __init__(self, maxGreen, maxYellow, message):
         """ stores limit information
             @param maxGreen
                         is the message printed when the limit is at least
                         more than maxGreen.
         """
-        self.maxGreen  = maxGreen
+        self.maxGreen = maxGreen
         self.maxYellow = maxYellow
-        self.message   = message
+        self.message = message
 
     def isGreenFor(self, value):
         """ Checking for a value to be in a valid range.
         """
         prompt = "%s" % pathAndFileName
 
-        if lineNr >= 0: prompt += "(%d): " % lineNr
-        else:           prompt += "(1): "
+        if lineNr >= 0:
+            prompt += "(%d): " % lineNr
+        else:
+            prompt += "(1): "
 
-        if value > self.maxYellow: prompt += "error: "
-        else:                      prompt += "warning: "
+        if value > self.maxYellow:
+            prompt += "error: "
+        else:
+            prompt += "warning: "
 
         return prompt + self.message + ", value is %d" % value + \
-               " (green<=%d,yellow>=%d,red>=%d)" % \
-               (self.maxGreen, self.maxGreen+1, self.maxYellow+1)
+            " (green<=%d,yellow>=%d,red>=%d)" % \
+            (self.maxGreen, self.maxGreen + 1, self.maxYellow + 1)
+
 
 class Limits:
+
     """ Does group all limits to be checked by this scripts """
+
     def __init__(self):
         """ initializes container for limit defintions only """
         self.definitions = {}
         """ <b>Too many attributes per class</b>:<br>
             Is an indicator for bad design. Maybe the class is too complex or an
             improper way to store information has been used. """
-        return self.registerLimit(self.maxAttributesPerClass.__name__, \
-            GreenYellowRedLimit( 10,  15, "too many attributes in class"))
+        return self.registerLimit(self.maxAttributesPerClass.__name__,
+                                  GreenYellowRedLimit(10,  15, "too many attributes in class"))
 
     def maxFunctionsPerClass(self):
         """ <b>Too many functions per class</b>:<br>
             Is an indicator for bad design. Maybe the class does handle too much. """
-        return self.registerLimit(self.maxFunctionsPerClass.__name__, \
-            GreenYellowRedLimit( 15,  20, "too many functions in class"))
+        return self.registerLimit(self.maxFunctionsPerClass.__name__,
+                                  GreenYellowRedLimit(15,  20, "too many functions in class"))
 
     def maxFunctionsPerFile(self):
         """ <b>Too many functions per file</b>:<br>
             Is an indicator for bad design. You have too many logic in one file.
             The different to many functions per class is that global functions are
             counted as well as functions of multiple classes in same file. """
-        return self.registerLimit(self.maxFunctionsPerFile.__name__, \
-            GreenYellowRedLimit( 35,  40, "too many functions in file"))
+        return self.registerLimit(self.maxFunctionsPerFile.__name__,
+                                  GreenYellowRedLimit(35,  40, "too many functions in file"))
 
     def maxClassesPerFile(self):
         """ <b>Too many classes per file</b>:<br>
             Is an indicator for bad design and/or simply the fact that the file
             could be splitted up for different classes. """
-        return self.registerLimit(self.maxClassesPerFile.__name__, \
-            GreenYellowRedLimit(  4,   6, "too many classes in file"))
+        return self.registerLimit(self.maxClassesPerFile.__name__,
+                                  GreenYellowRedLimit(4,   6, "too many classes in file"))
 
     def maxParametersPerFunction(self):
         """ <b>Too many parameters in function/method</b>:<br>
             Is an indicator for bad design. Are many of those parameters also required
             by other functions or methods? Can't you provide a class or a dictionary? """
-        return self.registerLimit(self.maxParametersPerFunction.__name__, \
-            GreenYellowRedLimit(  3,   5, "too many parameters in function/method"))
+        return self.registerLimit(self.maxParametersPerFunction.__name__,
+                                  GreenYellowRedLimit(3,   5, "too many parameters in function/method"))
 
     def maxLinesPerFunction(self):
         """ <b>Too many lines per function/method</b>:<br>
             small; with this I can see about 50 lines of code. With an output window or
             other information at the bottom (IDE) you will see less than this. This metric
             includes comments, excludes blanks."""
-        return self.registerLimit(self.maxLinesPerFunction.__name__, \
-            GreenYellowRedLimit( 50, 100, "too many lines in function/method"))
+        return self.registerLimit(self.maxLinesPerFunction.__name__,
+                                  GreenYellowRedLimit(50, 100, "too many lines in function/method"))
 
     def maxControlStatementsPerFunction(self):
         """ <b>Too many control statements</b>:<br>
             Is an indicator that the function/method is too complex. """
-        return self.registerLimit(self.maxControlStatementsPerFunction.__name__, \
-            GreenYellowRedLimit( 15,  20, "too many control statements"))
+        return self.registerLimit(
+            self.maxControlStatementsPerFunction.__name__,
+            GreenYellowRedLimit(15,  20, "too many control statements"))
 
     def maxCharactersPerLine(self):
         """ <b>Line too long</b>:<br>
             is when you use tools for comparing two versions (side by side) or
             when printing it out; it's to avoid wrapping code into the next lines.
             <b>It's about readability!</b> """
-        return self.registerLimit(self.maxCharactersPerLine.__name__, \
-            GreenYellowRedLimit( 95, 110, "line too long"))
+        return self.registerLimit(self.maxCharactersPerLine.__name__,
+                                  GreenYellowRedLimit(95, 110, "line too long"))
 
     def maxLinesPerFile(self):
         """ <b>Too many lines in file</b>:<br>
             Is an indicator for bad design. I know from files with several thousand
             lines of code and especially those file mostly are difficult to maintain.
             This metric includes comments, excludes blank lines. """
-        return self.registerLimit(self.maxLinesPerFile.__name__, \
-            GreenYellowRedLimit(550, 750, "too many lines in file"))
+        return self.registerLimit(self.maxLinesPerFile.__name__,
+                                  GreenYellowRedLimit(550, 750, "too many lines in file"))
 
     def maxIndentationLevel(self):
         """ <b>Too many indentation levels</b>:<br>
             Is an indicator that the code is too complex! It's about examples like having
             an if statement containing an if statement and again containing an if
             statement and again ... """
-        return self.registerLimit(self.maxIndentationLevel.__name__, \
-            GreenYellowRedLimit(  3,   5, "too many indentation levels"))
+        return self.registerLimit(self.maxIndentationLevel.__name__,
+                                  GreenYellowRedLimit(3,   5, "too many indentation levels"))
 
     def maxTabs(self):
         """ <b>Too many tabs</b>:<br>
             This a visual style issue. You can disallow tabs if wanted.
             Default: no tabs are allowed. """
-        return self.registerLimit(self.maxTabs.__name__, \
-            GreenYellowRedLimit(  0,   0, "too many tabs"))
+        return self.registerLimit(self.maxTabs.__name__,
+                                  GreenYellowRedLimit(0,   0, "too many tabs"))
 
-FILE     = 0
-CLASS    = 1
+FILE = 0
+CLASS = 1
 FUNCTION = 2
-LINENR   = 3
-LEVEL    = 4
+LINENR = 3
+LEVEL = 4
+
 
 class FileData:
+
     """ represent all information for one file from one analyse """
+
     def __init__(self, pathAndFileName):
         """ initializes members for one file analyse """
         self.pathAndFileName = pathAndFileName
-        self.classes         = {}
-        self.attributes      = {}
-        self.functions       = {}
+        self.classes = {}
+        self.attributes = {}
+        self.functions = {}
 
-        self.errors          = 0
-        self.warnings        = 0
-        self.totalLines      = 0
+        self.errors = 0
+        self.warnings = 0
+        self.totalLines = 0
         self.totalBlankLines = 0
-        self.messages        = []
+        self.messages = []
+
 
 class SimplePythonChecker(ast.NodeVisitor):
+
     """ As visitor on one side it can traverse the python code
         for checking structural things. Comments, length of lines,
         indentation depth are topic which need to be handled separately.
         @note The tool does not check whether somebody creates attributes
               outside of the __init__ method.
     """
+
     def __init__(self):
         """ initializing to have some empty containers and the limits """
-        self.limits     = Limits()
-        self.current    = {LEVEL: 0}
-        self.files      = {}
+        self.limits = Limits()
+        self.current = {LEVEL: 0}
+        self.files = {}
 
     def analyze(self, pathAndFileName):
         """ main method for analyzing one python file
         # remember the current file for further processing
         newFileData = FileData(pathAndFileName)
         self.files[pathAndFileName] = newFileData
-        self.current[FILE]          = newFileData
+        self.current[FILE] = newFileData
 
         # the content of the whole file
         code = open(pathAndFileName).read()
-        # collecting relevant information for limit checking walking the AST tree.
+        # collecting relevant information for limit checking walking the AST
+        # tree.
         tree = ast.parse(code)
         self.visit(tree)
         # line based analyse
         currentFile = self.current[FILE]
 
         # checking all line lengths for given file (code)
-        lineNr       = 1
+        lineNr = 1
         for line in code.split('\n'):
             # checking for line length
             limitToCheck = self.limits.maxCharactersPerLine()
-            value        = len(line)
+            value = len(line)
             self.checkLimit(lineNr, limitToCheck, value)
 
             # checking for tabs in line
             limitToCheck = self.limits.maxTabs()
-            value        = line.count("\t")
+            value = line.count("\t")
             self.checkLimit(lineNr, limitToCheck, value)
 
             # counting blank lines
             if len(line.strip()) == 0:
                 currentFile.totalBlankLines += 1
-                functions = [ function for function in currentFile.functions.values() \
-                              if function["lineNr"]                   < lineNr and \
-                                 function["lineNr"]+function["lines"] > lineNr ]
+                functions = [function for function in currentFile.functions.values()
+                             if function["lineNr"] < lineNr and
+                             function["lineNr"] + function["lines"] > lineNr]
 
                 if len(functions) == 1:
                     functions[0]["blankLines"] += 1
 
         # checking number of lines in given file (code)
         limitToCheck = self.limits.maxLinesPerFile()
-        lineNr       = 1
-        value        = code.count("\n") + 1
-        self.checkLimit(lineNr, limitToCheck, value - currentFile.totalBlankLines)
+        lineNr = 1
+        value = code.count("\n") + 1
+        self.checkLimit(
+            lineNr, limitToCheck, value - currentFile.totalBlankLines)
 
         currentFile.totalLines = value
 
         """
         currentFile = self.current[FILE]
 
-        newClass               = {}
-        newClass["lineNr"]     = node.lineno
+        newClass = {}
+        newClass["lineNr"] = node.lineno
         newClass["attributes"] = set()
-        newClass["functions"]  = set()
+        newClass["functions"] = set()
 
         currentFile.classes[node.name] = newClass
         self.current[CLASS] = node.name
         currentFile = self.current[FILE]
 
         if FUNCTION in self.current and self.current[FUNCTION] == "__init__":
-            newAttribute           = {}
+            newAttribute = {}
             newAttribute["lineNr"] = node.lineno
 
             # provide class information (when available)
             if CLASS in self.current and self.current[CLASS]:
                 newAttribute["class"] = self.current[CLASS]
-                currentFile.classes[self.current[CLASS]]["attributes"].add(node.attr)
+                currentFile.classes[self.current[CLASS]][
+                    "attributes"].add(node.attr)
 
             currentFile.attributes[node.attr] = newAttribute
         self.generic_visit(node)
         """
         currentFile = self.current[FILE]
 
-        newFunction               = {}
-        newFunction["lineNr"]     = node.lineno
-        newFunction["cstms"]      = 0
+        newFunction = {}
+        newFunction["lineNr"] = node.lineno
+        newFunction["cstms"] = 0
         newFunction["blankLines"] = 0
 
         # this is because of handling different python versions...
-        try:    newFunction["argumentNames"] = [arg.arg for arg in node.args.args]
-        except: newFunction["argumentNames"] = [arg.id for arg in node.args.args]
+        try:
+            newFunction["argumentNames"] = [arg.arg for arg in node.args.args]
+        except:
+            newFunction["argumentNames"] = [arg.id for arg in node.args.args]
 
         # provide class information (when available)
         if CLASS in self.current and self.current[CLASS]:
         self.generic_visit(node)
         # calcuates number of lines of function/method
         newFunction["lines"] = self.current[LINENR] - node.lineno
-        self.current[FUNCTION]  = None
+        self.current[FUNCTION] = None
 
     def visit_If(self, node):
         """ required to check for indentation level and complexity """
         self.current[LEVEL] += 1
 
         limitToCheck = self.limits.maxIndentationLevel()
-        lineNr       = node.lineno
-        value        = self.current[LEVEL]
+        lineNr = node.lineno
+        value = self.current[LEVEL]
 
         self.checkLimit(lineNr, limitToCheck, value)
 
         self.current[LEVEL] += 1
 
         limitToCheck = self.limits.maxIndentationLevel()
-        lineNr       = node.lineno
-        value        = self.current[LEVEL]
+        lineNr = node.lineno
+        value = self.current[LEVEL]
 
         self.checkLimit(lineNr, limitToCheck, value)
 
         self.current[LEVEL] += 1
 
         limitToCheck = self.limits.maxIndentationLevel()
-        lineNr       = node.lineno
-        value        = self.current[LEVEL]
+        lineNr = node.lineno
+        value = self.current[LEVEL]
 
         self.checkLimit(lineNr, limitToCheck, value)
 
         for className in currentFile.classes:
             # checking for number of attributes/members per class
             limitToCheck = self.limits.maxAttributesPerClass()
-            value        = len(currentFile.classes[className]["attributes"])
-            lineNr       = currentFile.classes[className]["lineNr"]
+            value = len(currentFile.classes[className]["attributes"])
+            lineNr = currentFile.classes[className]["lineNr"]
             self.checkLimit(lineNr, limitToCheck, value)
 
             # checking for number of functions/methods per class
             limitToCheck = self.limits.maxFunctionsPerClass()
-            value        = len(currentFile.classes[className]["functions"])
+            value = len(currentFile.classes[className]["functions"])
             self.checkLimit(lineNr, limitToCheck, value)
 
         for functionName in currentFile.functions:
             # checking for number of parameters per function/method
             limitToCheck = self.limits.maxParametersPerFunction()
-            lineNr       = currentFile.functions[functionName]["lineNr"]
-            value        = len(currentFile.functions[functionName]["argumentNames"])
+            lineNr = currentFile.functions[functionName]["lineNr"]
+            value = len(
+                currentFile.functions[functionName]["argumentNames"])
 
             if "self" in currentFile.functions[functionName]["argumentNames"]:
                 value -= 1
 
             # checking for number of lines per function/method
             limitToCheck = self.limits.maxLinesPerFunction()
-            value        = currentFile.functions[functionName]["lines"]
-            value       -= currentFile.functions[functionName]["blankLines"]
+            value = currentFile.functions[functionName]["lines"]
+            value -= currentFile.functions[functionName]["blankLines"]
             self.checkLimit(lineNr, limitToCheck, value)
             # checking for number of control statements per function/method
             limitToCheck = self.limits.maxControlStatementsPerFunction()
-            value        = currentFile.functions[functionName]["cstms"]
+            value = currentFile.functions[functionName]["cstms"]
             self.checkLimit(lineNr, limitToCheck, value)
 
-
         # checking number of functions/methods per file
         limitToCheck = self.limits.maxFunctionsPerFile()
-        value        = len(currentFile.functions)
-        lineNr       = 1
+        value = len(currentFile.functions)
+        lineNr = 1
         self.checkLimit(lineNr, limitToCheck, value)
         # checking number of classes per file
         limitToCheck = self.limits.maxClassesPerFile()
-        value        = len(currentFile.classes)
+        value = len(currentFile.classes)
         self.checkLimit(lineNr, limitToCheck, value)
 
     def checkLimit(self, lineNr, limitToCheck, value):
         currentFile = self.current[FILE]
 
         if not limitToCheck.isGreenFor(value):
-            message = limitToCheck.getMessage(currentFile.pathAndFileName, lineNr, value)
+            message = limitToCheck.getMessage(
+                currentFile.pathAndFileName, lineNr, value)
             currentFile.messages.append((lineNr, message))
-            if limitToCheck.isRedFor(value): currentFile.errors   += 1
-            else:                            currentFile.warnings += 1
+            if limitToCheck.isRedFor(value):
+                currentFile.errors += 1
+            else:
+                currentFile.warnings += 1
 
     def generic_visit(self, node):
         """ main reason for overwriting this method is to be able to
             calculate how many line are in a block (function/method/class/...) """
-        try:    self.current[LINENR] = node.lineno
-        except: pass
+        try:
+            self.current[LINENR] = node.lineno
+        except:
+            pass
         # traverse further nodes
         ast.NodeVisitor.generic_visit(self, node)
 
         for message in sorted(currentFile.messages):
             print(message[1])
 
-        functions = [name for name in currentFile.functions \
-                     if len(currentFile.functions[name]["argumentNames"]) == 0 or \
-                        not currentFile.functions[name]["argumentNames"][0] == 'self']
+        functions = [name for name in currentFile.functions
+                     if len(currentFile.functions[name]["argumentNames"]) == 0 or
+                     not currentFile.functions[name]["argumentNames"][0] == 'self']
 
-        print("...%3d lines processed (with %d blank lines)" \
+        print("...%3d lines processed (with %d blank lines)"
               % (currentFile.totalLines, currentFile.totalBlankLines))
         print("...%3d function(s) processed" % len(functions))
-        print("...%3d method(s) processed" % (len(currentFile.functions) - len(functions)))
-        print("...%3d warning(s) - %d error(s)" \
+        print("...%3d method(s) processed" %
+              (len(currentFile.functions) - len(functions)))
+        print("...%3d warning(s) - %d error(s)"
               % (currentFile.warnings, currentFile.errors))
 
+
 def main():
     """ script can be executed with filename as parameter, otherwise the
         script itself will be checked """

lab/testassist.py

 prj = rope.base.project.Project(".")
 src = example
 offset = len(src)
+
+
 def test():
     for i in range(1000):
         code_assist(prj, src, offset, resource=None, maxfixes=3)
 
-    
+
 test()
 
 
 class Parameters(object):
-    
+
     def __init__(self):
         self.types = None
         self.rtype = None
-        
+
     def __repr__(self):
         return repr(self.__dict__)
 
 
 class Method(object):
-    
+
     def __init__(self):
         self.callers = []
         self.defined_at = None
     def __repr__(self):
         return repr(self.__dict__)
 
-    
+
 class Class(object):
-    
+
     def __init__(self):
         self.methods = {}
 
 
-
-
 class Tracer(object):
-    
 
     def __init__(self):
-        self.classes = {None: {None:{}}}
+        self.classes = {None: {None: {}}}
         self.current_call = []
 
-        
     def enable(self):
         sys.settrace(self.trace_it)
 
-        
     def disable(self):
         sys.settrace(None)
 
-
     def trace_it(self, frame, event, arg):
         # http://docs.python.org/library/inspect.html
         if event == "line":
                 filename = filename[:-1]
             name = frame.f_globals["__name__"]
             line = linecache.getline(filename, lineno)
-            #print "LINE %s:%d: %s" % (name, lineno, line.rstrip())
+            # print "LINE %s:%d: %s" % (name, lineno, line.rstrip())
         elif event in ("call", "c_call"):
-            arginfo  = inspect.getargvalues(frame)
+            arginfo = inspect.getargvalues(frame)
             if arginfo.args and arginfo.args[0] == "self":
                 # assume method
                 self.trace_method(frame, arginfo)
             print "EVENT is", event
         return self.trace_it
 
-    
     def trace_return(self, frame, result):
         params = self.current_call.pop()
         if params is not None:
             params.rtype = type(result).__name__
 
-    
     def trace_method(self, frame, arginfo):
         line = frame.f_lineno
         arg_names, arg_values = arginfo.args, arginfo.locals
 
 def main():
     foo = "bar"
-    #test_func(1)
+    # test_func(1)
     o = TestObj()
     o.test_method(4)
     o.test_method(mp=5.6)
     print "class", cls_name, cls
     for method_name, method in cls.methods.items():
         for (arg_names, arg_types), param in method.parameters.items():
-            print "\tdef", method_name, zip(arg_names, arg_types), "->", param.rtype
+            print "\tdef", method_name, zip(arg_names, arg_types), "->", param.rtype
     _async_method = handler
 
 
-
 def sync_call(func, *args, **kwargs):
     callback = kwargs.pop("callback")
     result = func(*args, **kwargs)
     callback(result)
 
 
-
 class _AsyncThread(Thread):
 
-        
     def run(self):
         kwargs = self.kwargs
         callback = kwargs.pop("callback")
         callback(result)
 
 
-        
 def threaded_call(func, *args, **kwargs):
-    t = _AsyncThread(args=(func,)+args, kwargs=kwargs)
+    t = _AsyncThread(args=(func,) + args, kwargs=kwargs)
     t.start()
 
-    
+
 def async(func):
     def wrapper(*args, **kwargs):
         _async_method(func, *args, **kwargs)
     return wrapper
 
 
-
 class ServiceRoot(object):
     pass
 
 
     con = Connection(create_server)
     con.start()
-    
+
     return IpcClient(con)
-
-
-    

pycode/__init__.py

 # http://code.google.com/p/spyderlib/source/browse/spyderlib/utils/codeanalysis.py
 # http://code.google.com/p/spyderlib/source/browse/spyderlib/utils/module_completion.py
 # (Copyright © 2011 Pierre Raybaut, Licensed under the terms of the MIT License)
-
-						
-	
 import tempfile
 
 
-TASKS_PATTERN = (r"#? ?TODO ?:?[^#]*|#? ?FIXME ?:?[^#]*|"\
-                r"#? ?XXX ?:?[^#]*|#? ?HINT ?:?[^#]*|#? ?TIP ?:?[^#]*")
-
+TASKS_PATTERN = (r"#? ?TODO ?:?[^#]*|#? ?FIXME ?:?[^#]*|"
+                 r"#? ?XXX ?:?[^#]*|#? ?HINT ?:?[^#]*|#? ?TIP ?:?[^#]*")
 
 
 def tasks(project, source_code):
     results = []
     for line, text in enumerate(source_code.splitlines()):
         for todo in re.findall(TASKS_PATTERN, text):
-            results.append((todo, line+1))
+            results.append((todo, line + 1))
     return results
 
 
-
 def flakes(project, source_code, filename=None):
     """
     Check source code with pyflakes
         results = []
         lines = source_code.splitlines()
         for warning in w.messages:
-            if 'analysis:ignore' not in lines[warning.lineno-1]:
-                results.append((warning.message % warning.message_args, warning.lineno))
+            if 'analysis:ignore' not in lines[warning.lineno - 1]:
+                results.append(
+                    (warning.message % warning.message_args, warning.lineno))
         return results
 
 
-
 def _check_external(args, source_code, filename=None, options=None):
     """
     Check source code with checker defined with *args* (list)
     return output
 
 
-
 def pep8(project, source_code, filename=None):
     """
     Check source code with pep8
     source = source_code.splitline()
     for line in _check_external(args, source_code, filename=filename, options=['-r']):
         lineno = int(re.search(r'(\:[\d]+\:)', line).group()[1:-1])
-        if 'analysis:ignore' not in source[lineno-1]:  # nice idea from Spyder
-            message = line[line.find(': ')+2:]
+        # nice idea from Spyder
+        if 'analysis:ignore' not in source[lineno - 1]:
+            message = line[line.find(': ') + 2:]
             results.append((message, lineno))
     return results
 
 
-
 def lint(project, source_code, filename=None, errors_only=False):
     """
     Check source code with pylint
             if kind == "W":
                 msg = "Warning"
             else:
-                msg = "Error"    
+                msg = "Error"
             if func:
                 line = re.sub("\\[([WE])(, (.+?))?\\]",
                               "%s (%s):" % (msg, func), msg)
                 line = re.sub("\\[([WE])?\\]", "%s:" % msg, line)
             results.append((msg, line))
     return results
-    
     return encoding
 
 
-
 def load(filename):
     """
     :param filename: existing filenname
     return source.decode(encoding)
 
 
-
 def save(filename, source, tab_width=TAB_WIDTH, strip_blank_lines=STRIP_BLANK_LINES, untabify=UNTABIFY):
     """
     :param filename:
     :param untabify:
     :return:
     """
-    assert isinstance(source, unicode), "expected source code as unicode string"
+    assert isinstance(
+        source, unicode), "expected source code as unicode string"
     encoding = guess_encoding(source)
     tab = u" " * tab_width
     lines = source.splitlines()

pycode/indenter.py

 TAB_WIDTH = 4
 
 
+class _StatementRangeFinder(object):
 
-class _StatementRangeFinder(object):
     """A method object for finding the range of a statement"""
 
-    
     def __init__(self, lines, lineno):
         self.lines = lines
         self.lineno = lineno
         self.open_parens = []
         self._analyze()
 
-        
     def _analyze_line(self, lineno):
         current_line = self.lines.get_line(lineno)
         for i, char in enumerate(current_line):
                     if char * 3 == current_line[i:i + 3]:
                         self.in_string = char * 3
                 elif self.in_string == current_line[i:i + len(self.in_string)] and \
-                     not (i > 0 and current_line[i - 1] == '\\' and
-                          not (i > 1 and current_line[i - 2:i] == '\\\\')):
+                    not (i > 0 and current_line[i - 1] == '\\' and
+                         not (i > 1 and current_line[i - 2:i] == '\\\\')):
                     self.in_string = ''
             if self.in_string != '':
                 continue
         else:
             self.explicit_continuation = False
 
-            
     def _analyze(self):
         last_statement = 1
         block_start = codeanalyze.get_block_start(self.lines, self.lineno)
             self._analyze_line(current_line_number)
         self.statement_start = last_statement
 
-        
     def get_statement_start(self):
         return self.statement_start
 
-    
     def last_open_parens(self):
         if not self.open_parens:
             return None
         return self.open_parens[-1]
 
-    
     def is_line_continued(self):
         return self.open_count != 0 or self.explicit_continuation
 
-    
     def get_line_indents(self, line_number):
         return self._count_line_indents(self.lines.get_line(line_number))
 
 
-    
+class TextIndenter(object):
 
-
-
-
-class TextIndenter(object):
     """A class for formatting texts"""
 
-    
     def __init__(self, editor, indents=4):
         self.indents = indents
         self.line_editor = editor
 
-        
     def correct_indentation(self, lineno):
         """Correct the indentation of a line"""
 
-        
     def deindent(self, lineno):
         """
         Deindent the a line
         new_indents = max(0, current_indents - self.indents)
         self._set_line_indents(lineno, new_indents)
 
-        
     def indent(self, lineno):
         """
         Indent a line
         new_indents = current_indents + self.indents
         self._set_line_indents(lineno, new_indents)
 
-        
     def entering_new_line(self, lineno):
         """
         Indent a line
         else:
             self.correct_indentation(lineno)
 
-
     def insert_tab(self, index):
         """
         Inserts a tab or spaces in the given index
         """
         self.line_editor.insert(index, ' ' * self.indents)
 
-        
     def _set_line_indents(self, lineno, indents):
         old_indents = self._count_line_indents(lineno)
         indent_diffs = indents - old_indents
         self.line_editor.indent_line(lineno, indent_diffs)
 
-        
     def _count_line_indents(self, lineno):
         contents = self.line_editor.get_line(lineno)
         result = 0
         return result
 
 
-    
 class NormalIndenter(TextIndenter):
 
-    
     def __init__(self, editor):
         super(NormalIndenter, self).__init__(editor)
 
-        
     def correct_indentation(self, lineno):
         prev_indents = 0
         if lineno > 1:
         self._set_line_indents(lineno, prev_indents)
 
 
-        
 class PythonCodeIndenter(TextIndenter):
+
     """
     Content sensitive indention for Python
 
     :param editor: should implement the editor interface: length(), get_line(number), insert(pos, s), indent_line(number)
     :param indents: number of spaces (4 by default)
     """
-    
+
     def __init__(self, editor, indents=4):
         super(PythonCodeIndenter, self).__init__(editor, indents)
 
-        
     def _last_non_blank(self, lineno):
         current_line = lineno - 1
         while current_line != 1 and \
-              self.line_editor.get_line(current_line).strip() == '':
+                self.line_editor.get_line(current_line).strip() == '':
             current_line -= 1
         return current_line
 
-    
     def _get_correct_indentation(self, lineno):
         if lineno == 1:
             return 0
         new_indent += self._indents_caused_by_current_stmt(current_line)
         return new_indent
 
-    
     def _get_base_indentation(self, lineno):
         range_finder = _StatementRangeFinder(
             self.line_editor, self._last_non_blank(lineno))
         else:
             return self._count_line_indents(self._last_non_blank(lineno))
 
-        
     def _indents_caused_by_prev_stmt(self, stmt_range):
         first_line = self.line_editor.get_line(stmt_range[0])
         last_line = self.line_editor.get_line(stmt_range[1])
             new_indent -= self.indents
         return new_indent
 
-    
     def _startswith(self, line, tokens):
         line = self._strip(line)
         for token in tokens:
             if line == token or line.startswith(token + ' '):
                 return True
 
-            
     def _strip(self, line):
         try:
             numsign = line.rindex('#')
             pass
         return line.strip()
 
-    
     def _indents_caused_by_current_stmt(self, current_line):
         new_indent = 0
         stripped_current_line = self._strip(current_line)
         if self._startswith(current_line, ('elif',)):
             new_indent -= self.indents
         elif self._startswith(current_line, ('except',)) and \
-           stripped_current_line.endswith(':'):
+                stripped_current_line.endswith(':'):
             new_indent -= self.indents
         return new_indent
 
-    
     def correct_indentation(self, lineno):
         """
         Correct the indentation of the line containing the given index
         Use this in your editor
         """
         self._set_line_indents(lineno, self._get_correct_indentation(lineno))
-
-

pycode/libs/__init__.py

     if name.endswith(".zip"):
         zip_module = os.path.join(path, name)
         sys.path.insert(0, zip_module)
-

pycode/onlinehelp.py

 
 
 class ContextWrapper(object):
-    
+
     def __init__(self, d):
         self.d = d
-    
-        
+
     def lower(self, s):
         return s.lower()
-    
 
     def __getitem__(self, key):
         if "|" in key:
         return value_filter(self.d[key])
 
 
+class CodeHelp(object):
 
-class CodeHelp(object):
-    
     pattern = "(?P<module>\w+)\.(?P<function>\w+)"
     url = "http://docs.python.org/release/%(pyversion)s/library/%(module)s.html#%(module)s.%(function)s"
     context = {
-      "pyversion": ".".join(map(str, sys.version_info[:3]))
+        "pyversion": ".".join(map(str, sys.version_info[:3]))
     }
     context_wrapper = ContextWrapper
 
             ctx.update(found.groupdict())
             return self.url % self.context_wrapper(ctx)
 
-        
 
 class PyQtHelp(CodeHelp):
-    
+
     pattern = "PyQt4\.(QtCore|QtGui|QtNetwork)\.(?P<class>\w+)\.(?P<method>\w+)"
     url = "http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/%(class|lower)s.html#%(method)s"
 
 
-
 class WxClassHelp(CodeHelp):
     # api documentation used epydoc
     pattern = "wx\.(?P<class>\w+)\.(?P<method>\w+)"
     url = "http://wxpython.org/docs/api/wx.%(class)s-class.html#%(method)s"
 
-    
+
 class WxModuleHelp(CodeHelp):
     pattern = "wx\.(?P<module>\w+)\.(?P<class>\w+)\.(?P<method>\w+)"
     url = "http://wxpython.org/docs/api/wx.%(module)s.%(class)s-class.html#%(method)s"
 
 
 help_providers = [
-  PyQtHelp(),
-  WxModuleHelp(),
-  WxClassHelp(),
-  NumpyHelp(),
-  CodeHelp(),
+    PyQtHelp(),
+    WxModuleHelp(),
+    WxClassHelp(),
+    NumpyHelp(),
+    CodeHelp(),
 ]
 
+
 def help_url(name):
     """
     Context sensitive help for a function or class/method.
         if url:
             return url
 
-        
+
 if __name__ == "__main__":
     print help_url("re.sub")
     print help_url("PyQt4.QtGui.QPushButton.setText")

pycode/outline.py

         self.result.append(PythonASTOutlineNode(node))
 
 
-
 def _get_ast_children(node):
     visitor = _ASTDefinedVisitor()
     for child in ast.get_child_nodes(node):
     return visitor.result
 
 
-
 def outline(project, source_code):
     if isinstance(source_code, unicode):
         source_code = source_code.encode('utf-8')
     ast_node = ast.parse(source_code)
     return _get_ast_children(ast_node)
-
-

pycode/project.py

 import fnmatch
 
 
-
 class ProjectImporter(object):
 
     def guess_source_folders(self, root):
             # XXX: use heuristic to find packages?
             return [root]
 
-
     def settings(self, filename):
         prefs = {}
         prefs["project_name"] = self.project_name(filename)
     def project_root(self, path):
         return os.path.dirname(path)
 
-
     def project_name(self, path):
         return os.path.basename(os.path.dirname(path))
 
-
     def discover(self, path):
         filename = os.path.join(path, self.directory)
         if os.path.exists(filename):
             if self.validate(filename):
                 return [filename]
 
-
     def validate(self, path):
         return os.path.isdir(path)
 
 
     filename = None
 
-
     def project_root(self, filename):
         return os.path.dirname(filename)
 
-
     def project_name(self, path):
         return os.path.basename(os.path.dirname(path))
 
-
     def discover(self, path):
         filename = os.path.join(path, self.filename)
         if os.path.exists(filename):
             if self.validate(filename):
                 return [filename]
 
-