]> git.parisson.com Git - timeside.git/commitdiff
Fix several PEP8 warnings
authorThomas Fillon <thomas@parisson.com>
Tue, 22 Apr 2014 13:49:16 +0000 (15:49 +0200)
committerThomas Fillon <thomas@parisson.com>
Tue, 22 Apr 2014 13:49:16 +0000 (15:49 +0200)
timeside/component.py
timeside/core.py
timeside/exceptions.py
timeside/grapher/core.py
timeside/grapher/utils.py
timeside/tools/cache.py

index 7f7285293f9e1e6b999fbbcb59377172b7429388..a92ae1676bb68ff79feb40ce99fb586c376a7c27 100644 (file)
@@ -99,8 +99,8 @@ class MetaComponent(type):
             for i in MetaComponent.implements:
                 MetaComponent.implementations.append({
                     'interface': i,
-                    'class':     new_class,
-                    'abstract':  MetaComponent.abstract})
+                    'class': new_class,
+                    'abstract': MetaComponent.abstract})
 
         # Propagate @interfacedoc
         for name in new_class.__dict__:
index 6ef34f4c9faea77f5f315fc97932993ff4b802eb..0d68cc750323b31fc48329e1a28fc0e4019bd622 100644 (file)
@@ -49,7 +49,7 @@ class MetaProcessor(MetaComponent):
         new_class = MetaComponent.__new__(cls, name, bases, d)
         if new_class in implementations(IProcessor):
             id = str(new_class.id())
-            if _processors.has_key(id):
+            if id in _processors:
                 # Doctest test can duplicate a processor
                 # This can be identify by the conditon "module == '__main__'"
                 if new_class.__module__ == '__main__':
@@ -229,7 +229,7 @@ def processors(interface=IProcessor, recurse=True):
 
 def get_processor(processor_id):
     """Return a processor by its id"""
-    if not _processors.has_key(processor_id):
+    if not processor_id in _processors:
         raise Error("No processor registered with id: '%s'"
                     % processor_id)
 
index 09a9fa2404573bc98ffabc0a9e1a351b940753e1..3f369900b9ab855974605a76dcc2d3fb938fa104 100644 (file)
@@ -38,7 +38,7 @@ class SubProcessError(Error):
         self.subprocess = subprocess
 
     def __str__(self):
-        if self.subprocess.stderr != None:
+        if self.subprocess.stderr is not None:
             error = self.subprocess.stderr.read()
         else:
             error = ''
index 8708827eb5ae16cde69a26d74f66883f6b1300de..a77596e602a9a8602d8b7752d5fbe2281bf11a84 100644 (file)
@@ -102,7 +102,7 @@ class Spectrum(object):
 
         if energy > 1e-20:
             # calculate the spectral centroid
-            if self.spectrum_range == None:
+            if self.spectrum_range is None:
                 self.spectrum_range = numpy.arange(length)
             spectral_centroid = (spectrum * self.spectrum_range).sum() / \
                 (energy * (length - 1)) * \
index e3c525cb962202112971b5a21a843242e8d6910c..3dc62276ed37d931ca76572123b8fff0aef05412 100644 (file)
@@ -134,13 +134,13 @@ def smooth(x, window_len=10, window='hanning'):
     # instead of a string
 
     if x.ndim != 1:
-        raise ValueError, "smooth only accepts 1 dimension arrays."
+        raise ValueError("smooth only accepts 1 dimension arrays.")
     if x.size < window_len:
-        raise ValueError, "Input vector needs to be bigger than window size."
+        raise ValueError("Input vector needs to be bigger than window size.")
     if window_len < 3:
         return x
     if not window in ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']:
-        raise ValueError, "Window is on of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'"
+        raise ValueError("Window is on of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'")
 
     s = numpy.r_[2 * x[0] - x[window_len:1:-1],
                  x, 2 * x[-1] - x[-1:-window_len:-1]]
index 6681e1cfdc1d457b1b01cc760984d334bed389e9..592524add6f87602ad0b78f8a5ef7c60721b5cab 100644 (file)
@@ -66,7 +66,7 @@ class Cache(object):
 
     def read_bin(self, file):
         path = self.dir + os.sep + file
-        f = open(path,  'r')
+        f = open(path, 'r')
         data = f.read()
         f.close()
         return data
@@ -74,7 +74,7 @@ class Cache(object):
     def read_stream_bin(self, file):
         path = self.dir + os.sep + file
         chunk_size = 0x1000
-        f = open(path,  'r')
+        f = open(path, 'r')
         while True:
             _chunk = f.read(chunk_size)
             if not len(_chunk):