changeset 151:ace5ee1f185e

Refactor Rewindable
author Amine Sehili <amine.sehili@gmail.com>
date Fri, 22 Feb 2019 21:12:53 +0100
parents 6c1a11cf9e6a
children 71181bbe312a
files auditok/io.py
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/auditok/io.py	Fri Feb 22 20:55:19 2019 +0100
+++ b/auditok/io.py	Fri Feb 22 21:12:53 2019 +0100
@@ -309,30 +309,30 @@
         return self.channels
 
 
-class Rewindable:
+class Rewindable():
     """
     Base class for rewindable audio streams.
     Subclasses should implement methods to return to the beginning of an
     audio stream as well as method to move to an absolute audio position
     expressed in time or in number of samples. 
     """
+    @property
+    def rewindable(self):
+        return True
 
-    __metaclass__ = ABCMeta
-
-    @abstractmethod
     def rewind(self):
         """ Go back to the beginning of audio stream """
-        pass
+        raise NotImplementedError
 
-    @abstractmethod
+
     def get_position(self):
         """ Return the total number of already read samples """
+        raise NotImplementedError
 
-    @abstractmethod
     def get_time_position(self):
         """ Return the total duration in seconds of already read data """
+        raise NotImplementedError
 
-    @abstractmethod
     def set_position(self, position):
         """ Move to an absolute position 
 
@@ -341,8 +341,9 @@
             `position` : int
                 number of samples to skip from the start of the stream
         """
+        raise NotImplementedError
 
-    @abstractmethod
+
     def set_time_position(self, time_position):
         """ Move to an absolute position expressed in seconds
 
@@ -351,7 +352,7 @@
             `time_position` : float
                 seconds to skip from the start of the stream
         """
-        pass
+        raise NotImplementedError
 
 
 class BufferAudioSource(AudioSource, Rewindable):