]> git.parisson.com Git - timeside.git/commitdiff
Add a description function to all processors (@classmethod). Reformat timeside.core...
authorThomas Fillon <thomas@parisson.com>
Wed, 22 Oct 2014 15:05:39 +0000 (17:05 +0200)
committerThomas Fillon <thomas@parisson.com>
Fri, 24 Oct 2014 12:21:36 +0000 (14:21 +0200)
timeside/analyzer/irit_noise_startSilences.py
timeside/api.py
timeside/core.py

index bbea231be79ba4ba9ea86ff6d911fb7894128069..e820b93f71c9e0b5cb632a010329da004ead97f6 100644 (file)
@@ -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__()
index 38e7632fa4482f834324cf0af0da1832397db59e..f5a77395abbd482c97b6070d9a4a733945c1416c 100644 (file)
@@ -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):
 
index b981f67ef1a533f83604492e6b2e74010e781e91..1f45660a2e8d8a96c1328411c1223ba3bde77fab 100644 (file)
@@ -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):