]> git.parisson.com Git - timeside.git/commitdiff
- turn all such methods as name(), id(), file_extension() into static methods
authorOlivier Guilyardi <olivier@samalyse.com>
Thu, 26 Nov 2009 21:02:24 +0000 (21:02 +0000)
committerOlivier Guilyardi <olivier@samalyse.com>
Thu, 26 Nov 2009 21:02:24 +0000 (21:02 +0000)
- add the self argument to non static methods in interfaces for clarity
- encode api: the constructor doesn't conflict anymore with the new core, fixme gone

analyze/api.py
decode/api.py
encode/api.py
graph/api.py
tests/test.py

index b953b4171c91545e71b9b07ff4a23de75dd36de6..8091c613c6e2552abddbb44839894b6d4635987b 100644 (file)
@@ -24,18 +24,21 @@ from timeside.core import *
 class IAnalyzer(Interface):
     """Media item analyzer driver interface"""
 
+    @staticmethod
     def id():
         """Return a short id alphanumeric, lower-case string."""
 
+    @staticmethod
     def name():
         """Return the analyzer name, such as "Mean Level", "Max level",
         "Total length, etc..
         """
 
+    @staticmethod
     def unit():
         """Return the unit of the data such as "dB", "seconds", etc...
         """
 
-    def render(media, options=None):
+    def render(self, media, options=None):
         """Return the result data of the process"""
 
index 7963848a5affb54241b4a992107258f1d83d18f7..c25d15fdaf3a5e87cab3f97d2d10e9b166a3814b 100644 (file)
@@ -24,29 +24,28 @@ from timeside.core import Interface, TimeSideError
 class IDecoder(Interface):
     """Decoder driver interface"""
 
-    # Remark: the method prototypes do not include any self or cls argument 
-    # because an interface is meant to show what methods a class must expose 
-    # from the caller's point of view. However, when implementing the class 
-    # you'll obviously want to include this extra argument.
-
+    @staticmethod
     def format():
         """Return the decode/encoding format as a short string 
         Example: "MP3", "OGG", "AVI", ...
         """
    
+    @staticmethod
     def description():
         """Return a string describing what this decode format provides, is good 
         for, etc... The description is meant to help the end user decide what 
         format is good for him/her
         """
 
+    @staticmethod
     def file_extension():
         """Return the filename extension corresponding to this decode format"""
 
+    @staticmethod
     def mime_type():
         """Return the mime type corresponding to this decode format"""
 
-    def process(source, options=None):
+    def process(self, source, options=None):
         """Perform the decoding process and stream the result through a generator
 
         source is the audio/video source file absolute path.
index 628b1ddd07dd1591ff489c5d4e945a23894bbfab..ee9134efe944b68873d03679a4a2a719ce18e979 100644 (file)
@@ -24,13 +24,7 @@ from timeside.core import Interface, TimeSideError
 class IEncoder(Interface):
     """Encoder driver interface"""
 
-    # Remark: the method prototypes do not include any self or cls argument
-    # because an interface is meant to show what methods a class must expose
-    # from the caller's point of view. However, when implementing the class
-    # you'll obviously want to include this extra argument.
-
-    # FIXME: this constructor conflicts with the core component architecture
-    def __init__(output, nchannels, samplerate):
+    def __init__(self, output, nchannels, samplerate):
         """The constructor must always accept the output, nchannels and samplerate 
         arguments.  It may accepts extra arguments such as bitrate, depth, etc.., 
         but these must be optionnal, that is have a default value.
@@ -40,40 +34,44 @@ class IEncoder(Interface):
         block of binary data.
         """
 
+    @staticmethod
     def format():
         """Return the encode/encoding format as a short string
         Example: "MP3", "OGG", "AVI", ...
         """
 
+    @staticmethod
     def description():
         """Return a string describing what this encode format provides, is good
         for, etc... The description is meant to help the end user decide what
         format is good for him/her
         """
 
+    @staticmethod
     def file_extension():
         """Return the filename extension corresponding to this encode format"""
 
+    @staticmethod
     def mime_type():
         """Return the mime type corresponding to this encode format"""
 
-    def set_metadata(metadata):
+    def set_metadata(self, metadata):
         """metadata is a tuple containing tuples for each descriptor return by
         the dc.Ressource of the item, in the model order :
         ((name1, value1),(name2, value2),(name1, value3), ...)"""
 
-    def update():
+    def update(self):
         """Updates the metadata into the file passed as the output argument
            to the constructor. This method can't be called in streaming
            mode."""
 
-    def process(frames):
+    def process(self, frames):
         """Encode the frames passed as a numpy array, where columns are channels.
         
            In streaming mode the callback passed to the constructor is called whenever
            a block of encoded data is ready."""
 
-    def finish():
+    def finish(self):
         """Flush the encoded data and close the output file/stream. Calling this method
         may cause the streaming callback to be called if in streaming mode."""
   
index 3cfd223178885e095d35792154f34c9b37239329..1f9667a12d65ebc762de7803db511ce72956b50b 100644 (file)
@@ -25,9 +25,11 @@ from timeside.core import *
 class IGrapher(Interface):
     """Media item visualizer driver interface"""
 
+    @staticmethod
     def id():
         """Return a short id alphanumeric, lower-case string."""
 
+    @staticmethod
     def name():
         """Return the graph name, such as "Waveform", "Spectral view",
         etc..
@@ -38,5 +40,5 @@ class IGrapher(Interface):
         and scheme a a predefined color theme name"""
         pass
 
-    def render(media_item, width=None, height=None, options=None):
+    def render(self, media_item, width=None, height=None, options=None):
         """Generator that streams the graph output as a PNG image"""
index 8698e2d34e4d0aed2c60106cf43a6a6bee92292c..c282f944f30198ad24bbf7305b4421f709617eff 100755 (executable)
@@ -15,7 +15,7 @@ class TestAnalyzers(Component):
         for analyzer_class in self.analyzers:
             # FIXME: should access the name, id and unit member statically
             # there should be no need to instantiate analyzer_class
-            # eg: access directly analyzer_class.name, etc...
+            # eg: access directly analyzer_class.name(), etc...
             #
             # This remark is true at many places in this file
             analyzer = analyzer_class()