# HG changeset patch # User Amine Sehili # Date 1550866373 -3600 # Node ID ace5ee1f185ecf4200cd0aa470d44e3205ccf09b # Parent 6c1a11cf9e6a4919af793ac4d481b7b02bcf0416 Refactor Rewindable diff -r 6c1a11cf9e6a -r ace5ee1f185e auditok/io.py --- 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):