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__:
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__':
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)
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 = ''
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)) * \
# 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]]
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
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):