From: Thomas Fillon Date: Wed, 22 Oct 2014 15:05:39 +0000 (+0200) Subject: Add a description function to all processors (@classmethod). Reformat timeside.core... X-Git-Tag: 0.6~4^2~3 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=684a6a5aa524e264f740356daa53c1145e32f35d;p=timeside.git Add a description function to all processors (@classmethod). Reformat timeside.core.list_processors function --- diff --git a/timeside/analyzer/irit_noise_startSilences.py b/timeside/analyzer/irit_noise_startSilences.py index bbea231..e820b93 100644 --- a/timeside/analyzer/irit_noise_startSilences.py +++ b/timeside/analyzer/irit_noise_startSilences.py @@ -35,12 +35,13 @@ import os class IRITStartSeg(Analyzer): - implements(IAnalyzer) ''' Segmentation of recording sessions into 'start' and 'session' segments Properties: ''' + implements(IAnalyzer) + @interfacedoc def __init__(self): super(IRITStartSeg, self).__init__() diff --git a/timeside/api.py b/timeside/api.py index 38e7632..f5a7739 100644 --- a/timeside/api.py +++ b/timeside/api.py @@ -102,6 +102,12 @@ class IProcessor(Interface): def uuid(): """Return the UUID of the processor""" + @staticmethod + def description(): + """Return a string describing what this processor is meant for. + The description should provide enough information to help the end user. + """ + class IEncoder(IProcessor): diff --git a/timeside/core.py b/timeside/core.py index b981f67..1f45660 100644 --- a/timeside/core.py +++ b/timeside/core.py @@ -80,8 +80,8 @@ class Processor(Component, HasParam): Attributes: - parents : Dictionnary of parent Processors that must be processed - before the current Processor + parents : Dictionnary of parent Processors that must be + processed before the current Processor pipe : The ProcessPipe in which the Processor will run """ __metaclass__ = MetaProcessor @@ -104,7 +104,6 @@ class Processor(Component, HasParam): self.input_blocksize = 0 self.input_stepsize = 0 - @interfacedoc def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None): @@ -171,6 +170,16 @@ class Processor(Component, HasParam): def uuid(self): return str(self.UUID) + @interfacedoc + @classmethod + def description(self): + try: + descr = self.__doc__.lstrip().split('\n')[0] + except AttributeError: + return '*** NO DESCRIPTION FOR THIS PROCESSOR ***' + + return descr + @property def force_samplerate(self): return None @@ -206,8 +215,8 @@ class FixedSizeInputAdapter(object): self.pad = pad def blocksize(self, input_totalframes): - """Return the total number of frames that this adapter will output according to the - input_totalframes argument""" + """Return the total number of frames that this adapter will output + according to the input_totalframes argument""" blocksize = input_totalframes if self.pad: @@ -218,9 +227,11 @@ class FixedSizeInputAdapter(object): return blocksize def process(self, frames, eod): - """Returns an iterator over tuples of the form (buffer, eod) where buffer is a - fixed-sized block of data, and eod indicates whether this is the last block. - In case padding is deactivated the last block may be smaller than the buffer size. + """Returns an iterator over tuples of the form (buffer, eod) + where buffer is a fixed-sized block of data, and eod indicates whether + this is the last block. + In case padding is deactivated the last block may be smaller than + the buffer size. """ src_index = 0 remaining = len(frames) @@ -272,12 +283,18 @@ def get_processor(processor_id): def list_processors(interface=IProcessor, prefix=""): print prefix + interface.__name__ + if len(prefix): + underline_char = '-' + else: + underline_char = '=' + print prefix + underline_char * len(interface.__name__) subinterfaces = interface.__subclasses__() for i in subinterfaces: list_processors(interface=i, prefix=prefix + " ") procs = processors(interface, False) for p in procs: - print prefix + " %s [%s]" % (p.__name__, p.id()) + print prefix + " - '%s' :" % p.id() + print prefix + " \t\t%s" % p.description() class ProcessPipe(object):