Commits

Andriy Kornatskyy committed 127bdf0

Fixed PEP8 warnings.

  • Participants
  • Parent commits 6229fab

Comments (0)

Files changed (11)

-syntax: glob                                                                   
-build/                                                                         
-dist/                                                                          
-env/                                                                           
-src/*.egg-info/                                                                
-.coverage                                                                      
-*.pyc                                                                          
-*.pyo                                                                          
-doc/_build
+syntax: glob
+build/
+dist/
+env/
+src/*.egg-info/
+.cache/
+.coverage
+*.pyc
+*.pyo
+doc/_build
 clean:
 	find src/ -type d -name __pycache__ | xargs rm -rf
 	find src/ -name '*.py[co]' -delete
-	rm -rf dist/ build/ MANIFEST src/*.egg-info
+	rm -rf dist/ build/ MANIFEST src/*.egg-info .cache .coverage
 
 release:
 	$(PYTHON) setup.py -q bdist_egg
 upload-dir = doc/_build
 
 [pytest]
+pep8ignore =

src/wheezy/caching/client.py

         """
         if namespace is None or namespace == self.default_namespace:
             return self.default_cache.set_multi(
-                    mapping, time, key_prefix, namespace)
+                mapping, time, key_prefix, namespace)
         else:
             context = self.namespaces[namespace]()
             cache = context.__enter__()
         """
         if namespace is None or namespace == self.default_namespace:
             return self.default_cache.add_multi(
-                    mapping, time, key_prefix, namespace)
+                mapping, time, key_prefix, namespace)
         else:
             context = self.namespaces[namespace]()
             cache = context.__enter__()
         """
         if namespace is None or namespace == self.default_namespace:
             return self.default_cache.replace_multi(
-                    mapping, time, key_prefix, namespace)
+                mapping, time, key_prefix, namespace)
         else:
             context = self.namespaces[namespace]()
             cache = context.__enter__()
             try:
                 return cache.replace_multi(
-                        mapping, time, key_prefix, namespace)
+                    mapping, time, key_prefix, namespace)
             finally:
                 context.__exit__(None, None, None)
 
         """
         if namespace is None or namespace == self.default_namespace:
             return self.default_cache.delete_multi(
-                    keys, seconds, key_prefix, namespace)
+                keys, seconds, key_prefix, namespace)
         else:
             context = self.namespaces[namespace]()
             cache = context.__enter__()
             try:
                 return cache.delete_multi(
-                        keys, seconds, key_prefix, namespace)
+                    keys, seconds, key_prefix, namespace)
             finally:
                 context.__exit__(None, None, None)
 
         """
         if namespace is None or namespace == self.default_namespace:
             return self.default_cache.incr(
-                    key, delta, namespace, initial_value)
+                key, delta, namespace, initial_value)
         else:
             context = self.namespaces[namespace]()
             cache = context.__enter__()
         """
         if namespace is None or namespace == self.default_namespace:
             return self.default_cache.decr(
-                    key, delta, namespace, initial_value)
+                key, delta, namespace, initial_value)
         else:
             context = self.namespaces[namespace]()
             cache = context.__enter__()

src/wheezy/caching/comp.py

 else:  # pragma: nocover
     # perform absolute import
     __saved_import__ = __import__
-    __import__ = lambda n, g=None, l=None, f=None:\
-            __saved_import__(n, g, l, f, 0)
+    __import__ = lambda n, g=None, l=None, f=None: \
+        __saved_import__(n, g, l, f, 0)
 
 if PY3:  # pragma: nocover
     from queue import Queue

src/wheezy/caching/dependency.py

             >>> c.get('key1')
             'key-x'
         """
-        return cache.add(self.next_key(cache, namespace),
-                key, self.time, namespace)
+        return cache.add(
+            self.next_key(cache, namespace),
+            key, self.time, namespace)
 
     def add_multi(self, cache, keys, key_prefix='', namespace=None):
         """ Adds several keys to dependency.
             >>> c.get('key4')
             'key-b'
         """
-        mapping = dict(zip(self.next_keys(cache, len(keys), namespace),
+        mapping = dict(zip(
+            self.next_keys(cache, len(keys), namespace),
             map(lambda k: key_prefix + k, keys)))
         return cache.add_multi(mapping, self.time, '', namespace)
 

src/wheezy/caching/memcache.py

         """ Client factory for python-memcache.
         """
         key_encode = kwargs.pop('key_encode', None)
-        return MemcachedClient(Client(*args, **kwargs),  key_encode)
+        return MemcachedClient(Client(*args, **kwargs), key_encode)
 except ImportError:  # pragma: nocover
     pass
 
         key_encode = self.key_encode
         keys, mapping = encode_keys(mapping, key_encode)
         failed = self.client.set_multi(
-                mapping, time, key_encode(key_prefix))
+            mapping, time, key_encode(key_prefix))
         return failed and [keys[key] for key in failed] or failed
 
     def add(self, key, value, time=0, namespace=None):
         """ Delete multiple keys at once.
         """
         key_encode = self.key_encode
-        return self.client.delete_multi(map(key_encode, keys),
-                seconds,
-                key_encode(key_prefix)) == 1
+        return self.client.delete_multi(
+            map(key_encode, keys),
+            seconds,
+            key_encode(key_prefix)) == 1
 
     def incr(self, key, delta=1, namespace=None, initial_value=None):
         """ Atomically increments a key's value. The value, if too

src/wheezy/caching/memory.py

         self.interval = bucket_interval
         self.items = {}
         self.lock = allocate_lock()
-        self.expire_buckets = [(allocate_lock(), [])
-                for i in xrange(0, buckets)]
+        self.expire_buckets = [
+            (allocate_lock(), []) for i in xrange(0, buckets)]
         self.last_expire_bucket_id = -1
 
     def __enter__(self):  # pragma: nocover
                 if initial_value is None:
                     return None
                 else:
-                    entry = items[key] = CacheItem(key,
-                            initial_value, expires(now, 0))
+                    entry = items[key] = CacheItem(
+                        key, initial_value, expires(now, 0))
             value = entry.value = entry.value + delta
             return value
         finally:

src/wheezy/caching/pylibmc.py

         for key in mapping:
             try:
                 client.replace(
-                        key_encode(key_prefix + key), mapping[key], time)
+                    key_encode(key_prefix + key), mapping[key], time)
             except NotFound:
                 failed.append(key)
         return failed
         """ Delete multiple keys at once.
         """
         key_encode = self.key_encode
-        return self.client.delete_multi(map(key_encode, keys),
-                key_encode(key_prefix))
+        return self.client.delete_multi(
+            map(key_encode, keys), key_encode(key_prefix))
 
     def incr(self, key, delta=1, namespace=None, initial_value=None):
         """ Atomically increments a key's value. The value, if too

src/wheezy/caching/tests/test_cache.py

 class CacheTestMixin(object):
 
     def setget(self, key, value):
-        assert self.client.set(key, value, 10, self.namespace) == True
+        assert self.client.set(key, value, 10, self.namespace) is True
         assert value == self.client.get(key, self.namespace)
 
     def setget_multi(self, mapping):
         assert None == self.client.get('uknown', self.namespace)
 
     def test_get_multi_notfound(self):
-        assert {} == self.client.get_multi(['unknown1', 'unknown2'],
-                namespace=self.namespace)
+        assert {} == self.client.get_multi(
+            ['unknown1', 'unknown2'], namespace=self.namespace)
 
     def test_getset(self):
         self.setget('s1', 'some string')
         mapping = {'a1': 1, 'a2': 2}
         assert self.client.add_multi(mapping, namespace=self.namespace) == []
         assert mapping == self.client.get_multi(
-                ['a1', 'a2'], namespace=self.namespace)
+            ['a1', 'a2'], namespace=self.namespace)
         assert ['a1', 'a2'] == self.client.add_multi(
-                mapping, namespace=self.namespace)
+            mapping, namespace=self.namespace)
 
     def test_replace(self):
         assert self.client.add('r', 100, namespace=self.namespace)
     def test_replace_multi(self):
         mapping = {'r1': 1, 'r2': 2}
         assert ['r1', 'r2'] == self.client.replace_multi(
-                mapping, namespace=self.namespace)
+            mapping, namespace=self.namespace)
         assert [] == self.client.add_multi(
-                mapping, namespace=self.namespace)
+            mapping, namespace=self.namespace)
         mapping = {'r1': 100, 'r2': 200}
         assert [] == self.client.replace_multi(
-                mapping, namespace=self.namespace)
+            mapping, namespace=self.namespace)
         assert mapping == self.client.get_multi(
-                ['r1', 'r2'], namespace=self.namespace)
+            ['r1', 'r2'], namespace=self.namespace)
 
     def test_delete(self):
         assert not self.client.delete('d', namespace=self.namespace)
 
     def test_incr(self):
         assert 1 == self.client.incr(
-                'ci', namespace=self.namespace, initial_value=0)
+            'ci', namespace=self.namespace, initial_value=0)
         assert 1 == self.client.get('ci', namespace=self.namespace)
         assert 2 == self.client.incr('ci', namespace=self.namespace)
         assert 2 == self.client.get('ci', namespace=self.namespace)
 
     def test_decr(self):
         assert 9 == self.client.decr(
-                'cd', namespace=self.namespace, initial_value=10)
+            'cd', namespace=self.namespace, initial_value=10)
         assert 9 == self.client.get('cd', namespace=self.namespace)
         assert 8 == self.client.decr('cd', namespace=self.namespace)
         assert 8 == self.client.get('cd', namespace=self.namespace)

src/wheezy/caching/tests/test_client.py

 
 cache1 = MemoryCache()
 cache2 = MemoryCache()
-cache_client = CacheClient(namespaces={
+cache_client = CacheClient(
+    namespaces={
         'cache1': lambda: cache1,
         'cache2': lambda: cache2
     },