Commits

Ronny Pfannschmidt committed a4f0796

mercyless application of unfiltered pep8.py

Comments (0)

Files changed (18)

 # All configuration values have a default value; values that are commented out
 # serve to show the default value.
 
-import sys, os
+import os
+import sys
 
 cur = os.path.abspath(__file__)
 base = os.path.dirname(os.path.dirname(cur))
 # List of documents that shouldn't be included in the build.
 #unused_docs = []
 
-# List of directories, relative to source directories, that shouldn't be searched
-# for source files.
+# List of directories, relative to source directories,
+# that shouldn't be searched for source files.
 exclude_trees = []
 
-# The reST default role (used for this markup: `text`) to use for all documents.
+# The reST default role (used for this markup: `text`) to use for all documents
 #default_role = None
 
 # If true, '()' will be appended to :func: etc. cross-reference text.
 #latex_font_size = '10pt'
 
 # Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, document class [howto/manual]).
+#source start file, target name, title, author, document class [howto/manual]
 latex_documents = [
   ('index', 'anyvc.tex', u'pu Documentation',
    u'Pida Team', 'manual'),

pu/commands/install.py

 """
 from pu.tasks.install import LinkPTH
 
+
 def link_command(config, queue):
     #XXX: handle fscked paths?
     #XXX: scripts
                    source=config.source,
                    site=config.site,
                    ))
-
-
 
     def __str__(self):
         return "<DistFile: %s>" % self.path
-
-
 '''
 from py.path import local
 
+
 class PthFile(object):
     def __init__(self, path):
         self.path = local(path)
             for path in self.entries:
                 rel = path.relto(self.path.dirpath())
                 if rel:
-                    f.write('./%s\n'%rel)
+                    f.write('./%s\n' % rel)
                 else:
-                    f.write('%s\n'%path)
-
-
+                    f.write('%s\n' % path)
     :copyright: 2010 by Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
 """
 
+
 class Queue(object):
     def __init__(self):
         self.depends = {}
                 if new_item is not None:
                     self.add(new_item, parent=k)
                     found.add(new_item)
-            if not v-self.completed:
+            if not v - self.completed:
                 self.runnable.add(k)
         return bool(found)
 
-
     def report_failure(self, t):
-        self.completed.add(t) #XXX: evil
+        #XXX: evil
+        self.completed.add(t)
         self.running.remove(t)
 
     def report_sucess(self, t):
     def run_all_possible(self):
         """runs all tasks it can complete
 
-        leaves the queue in a state where 
+        leaves the queue in a state where
         all completable tasks are completed
         """
         for item in self:
         self.run_all_possible()
         if len(self.completed) < len(self.depends):
             raise RuntimeError('not all tasks are executable')
-

pu/tasks/build.py

 from pu.tasks.util import TaskBase
 
+
 class CopyModulesToBuild(TaskBase):
     keys = 'source', 'build_lib'
 
         from py_compile import compile
         for x in self.build_lib.visit('*.py'):
             compile(str(x))
-
-
-

pu/tasks/install.py

 from pu.files.pth import PthFile
+
+
 class LinkTask(object):
     pth_name = 'pu-links.pth'
 
     def __init__(self, site, source):
         self.site = site
         self.source = source
+
     def __call__(self):
         self.run()
 
+
 class LinkPTH(LinkTask):
 
     def run(self):
         pth = PthFile(self.site.join(self.pth_name))
         pth.remove(self.source)
         pth.save()
-
-

pu/tasks/metadata.py

     def __call__(self):
         from pu.files.dist import DistFile
         self.result = DistFile(self.source.join('kij.yaml'))
-
-
 task_succeeded = ns.signal('task_succeeded')
 task_finished = ns.signal('task_finished')
 
+
 class TaskBase(object):
     """
     utility base class for implementing Tasks
     def __repr__(self):
         return '<%s %s>' % (
                 type(self).__name__,
-                ' '.join('%s=%r' % k 
+                ' '.join('%s=%r' % k
                     for k in self._key()))
 
     # reporting dispatch
 
         name = getattr(item, 'category', item.__class__.__name__.lower())
         method = 'on_%s_%s' % (name, base)
-        default_method = 'on_'+name
+        default_method = 'on_' + name
         if hasattr(self, method):
             return getattr(self, method)(item)
         elif hasattr(self, default_method):
                     sender=task)
             self.queue.append(task)
 
-
     def next(self):
         if self.queue is None:
             self.queue = deque()
             return self.queue.popleft()
         else:
             raise StopIteration
-
-
-

tests/cli/test_install.py

 from pu.commands.install import link_command
 from pu.task_queue import Queue
 
+
 def test_link_command(config, site):
     queue = Queue()
     link_command(config, queue)

tests/conftest.py

 from sanescript.config import Config
 
+
 def pytest_funcarg__site(request):
     tmpdir = request.getfuncargvalue('tmpdir')
     return tmpdir.ensure('site', dir=True)
 
+
 def pytest_funcarg__source(request):
     tmpdir = request.getfuncargvalue('tmpdir')
     return tmpdir.ensure('source', dir=True)
 
+
 def pytest_funcarg__config(request):
-    source = request.getfuncargvalue('source');
+    source = request.getfuncargvalue('source')
     site = request.getfuncargvalue('site')
     config = Config()
     config.grab_from_dict(dict(

tests/files/test_dist.py

+import py
+from pu.files.dist import DistFile, DistFileError
 
-import py
-
-from pu.files.dist import DistFile, DistFileError
 
 def pytest_funcarg__distfile(request):
     return request.getfuncargvalue('tmpdir').join('test-kij.yml')
 
+
 def pytest_funcarg__distfilegen(request):
     distfile = request.getfuncargvalue('distfile')
+
     def _create_file(s, distfile=distfile):
         f = distfile.open('w')
         f.write(s)
         return DistFile(distfile)
     return _create_file
 
+
 d = """
 name: Kij
 summary: Python packaging utilities
     - anyvc.*
 """
 
+
 def test_name(distfilegen):
     df = distfilegen(d)
     assert df.name == 'Kij'
     - anyvc.*
 """
 
+
 def test_missing_name(distfilegen):
     py.test.raises(DistFileError, distfilegen, e)
 
+
 def test_summary(distfilegen):
     df = distfilegen(d)
     assert df.summary == 'Python packaging utilities'
 
+
 def test_packages(distfilegen):
     df = distfilegen(d)
     assert df.packages[0] == 'anyvc.*'
     assert len(df.packages) == 1
 
+
 f = """
 name: banana
 """
 
+
 def test_missing_packages_ok(distfilegen):
     df = distfilegen(f)
     assert df.packages is None
 
+
 g = """
 name: banana
 packages: manana
 """
 
+
 def test_bad_packages(distfilegen):
     py.test.raises(DistFileError, distfilegen, g)
-

tests/files/test_pth.py

 import py
 from pu.files.pth import PthFile
 
+
 def pytest_funcarg__pthfile(request):
     return request.getfuncargvalue('tmpdir').join('test.pth')
 
+
 def pytest_funcarg__pth(request):
     return PthFile(request.getfuncargvalue('pthfile'))
 
+
 def pytest_funcarg__item(request):
     tmpdir = request.getfuncargvalue('tmpdir')
     return tmpdir.join('test-1.3.zip')
 
+
 def test_instanciate(tmpdir):
     PthFile(tmpdir.join('test.pthfail'))
 
+
 def test_create_pth(tmpdir):
     file = tmpdir.join('test.pth')
     pth = PthFile(file)
     assert not pth.entries
 
+
 def test_append(pth, tmpdir, item):
 
     pth.append(item)
     pth.append(item)
     assert pth.entries == [item]
 
+
 def test_remove(pth, tmpdir, item):
 
     pth.append(item)
     pth.remove(item)
     assert pth.entries == []
 
+
 def test_save_relative(pth, pthfile, tmpdir, item):
     pth.append(item)
     pth.save()
     assert pthfile.read() == './test-1.3.zip\n'
 
+
 def test_save_absolute(pth, pthfile):
     pth.append(py.path.local('/usr/local/lib'))
     pth.save()
     pth = PthFile(pthfile)
     assert pth.entries == [item]
 
+
 def test_parse_absolute(pthfile):
     pthfile.write('/usr/local/bin/test')
     pth = PthFile(pthfile)
     assert pth.entries == ['/usr/local/bin/test']
-
-

tests/tasks/test_build.py

 from pu.tasks.build import CopyModulesToBuild, CompileByteCode
 from pu.task_queue import Queue
 
+
 def test_copy_build(source, tmpdir):
     source.ensure('testpkg/__init__.py')
     source.join('kij.yml').write('name: test\npackages: testpkg\n')
     queue = Queue()
 
     source.ensure('testpkg/__init__.py')
-    build_lib=tmpdir.join('build/lib')
+    build_lib = tmpdir.join('build/lib')
 
     copy = CopyModulesToBuild(
         source=source,
     queue.add(copy, parent=compile)
 
     queue.run_all()
-    target =  build_lib.join('testpkg/__init__.pyc')
+    target = build_lib.join('testpkg/__init__.pyc')
     assert build_lib.join('testpkg/__init__.py').check()
     assert target.check()
+
     import imp
     magic = imp.get_magic()
     target_magic = target.read()[:4]
     assert target_magic == magic
-

tests/tasks/test_develop.py

 from pu.files.pth import PthFile
 
 
-
 def test_enable(site, source):
     task = LinkPTH(site, source)
     assert not site.join(task.pth_name).check()
     task.run()
     assert site.join(task.pth_name).check()
 
+
 def test_disable(site, source):
     test_enable(site, source)
 
 
     pth = PthFile(site.join(task.pth_name))
     assert source not in pth.entries
-

tests/tasks/test_metadata.py

 from pu.tasks.metadata import FindPackages, find_packages
 from pu.tasks.metadata import ReadYamlMetadata
 
+
 def test_find_packages(source):
     pkg = source.join('pkg')
     assert find_packages(source, pkg) == []
     assert task.result == ['pkg']
 
 
-
-
 def test_read_yaml_task(source):
     source.join('kij.yaml').write('name: test\npackages: [foo, bar]')
     task = ReadYamlMetadata(source=source)

tests/tasks/test_util.py

 import py
 from pu.tasks.util import TaskBase, task_succeeded, task_failed
 from pu.task_queue import Queue
+
+
 class Omg(TaskBase):
     keys = ()
 
     def __call__(self):
         pass
 
+
 class NeedOmg(Omg):
     keys = ()
     requirements = Omg,
     def on_u_success(self, item):
         return item.name
 
+
 def test_base():
     py.test.raises(KeyError, U, )
 
         assert task_succeeded.send(o)[0][1] is None
 
 
-
 def test_requirement():
     queue = Queue()
     task = NeedOmg()

tests/test_task_queue.py

 from pu.task_queue import Queue
 from pu.tasks.install import LinkPTH
 
+
 class SimpleTask(object):
+
     def __init__(self, number):
         self.number = number
         self.ndeps = number
 
 def test_simple():
     queue = Queue()
-    queue.add(SimpleTask(1)) # will create SimpleTask(0) as dependency
+    # will create SimpleTask(0) as dependency
+    queue.add(SimpleTask(1))
     first_task = next(queue)
     assert first_task.number == 0
 
     queue.report_sucess(next_task)
     py.test.raises(StopIteration, next, queue)
 
+
 def test_adding_the_same_twice_has_no_effect():
     queue = Queue()
     queue.add(SimpleTask(0))
     assert len(queue.completed) == 4
 
 
-
 def test_dependency_cycle_wont_complete_all():
     queue = Queue()
     base = SimpleTask(1)
     assert set(queue.depends) > queue.completed
 
     py.test.raises(RuntimeError, queue.run_all)
-