common: move AttributeHolder

This commit is contained in:
Roman Zeyde
2015-01-16 09:50:29 +02:00
parent 904966365f
commit babd4a5438
2 changed files with 10 additions and 6 deletions

View File

@@ -66,7 +66,7 @@ def detector(config, src):
error_index = flags.index(False)
message = 'too {0} signal'.format(errors[error_index])
yield AttributeHolder(dict(
yield common.AttributeHolder(dict(
freq=freq, rms=rms, peak=peak, coherency=coherency,
total=total, error=error, message=message
))
@@ -74,11 +74,6 @@ def detector(config, src):
pass
class AttributeHolder(object):
def __init__(self, d):
self.__dict__.update(d)
def recv(config, src, verbose=False):
fmt = '{0.freq:6.0f} Hz: {0.message:s}'
if verbose:

View File

@@ -72,3 +72,12 @@ class Dummy(object):
def __call__(self, *args, **kwargs):
return self
class AttributeHolder(object):
def __init__(self, d):
self.__dict__.update(d)
def __repr__(self):
return '{}({})'.format(self.__class__.__name__, self.__dict__)