Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2163 from forslund/bugfix/metaclass
Browse files Browse the repository at this point in the history
Fix obsolete metaclass declarations.
  • Loading branch information
forslund committed Jun 14, 2019
2 parents 52cd352 + 5211e51 commit e9879d9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
5 changes: 1 addition & 4 deletions mycroft/audio/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
from abc import ABCMeta, abstractmethod


class AudioBackend:
class AudioBackend(metaclass=ABCMeta):
"""
Base class for all audio backend implementations.
Args:
config: configuration dict for the instance
bus: Mycroft messagebus emitter
"""
__metaclass__ = ABCMeta

def __init__(self, config, bus):
self._track_start_callback = None
Expand Down Expand Up @@ -115,7 +114,6 @@ def restore_volume(self):
"""
pass

@abstractmethod
def seek_forward(self, seconds=1):
"""
Skip X seconds
Expand All @@ -125,7 +123,6 @@ def seek_forward(self, seconds=1):
"""
pass

@abstractmethod
def seek_backward(self, seconds=1):
"""
Rewind X seconds
Expand Down
26 changes: 8 additions & 18 deletions mycroft/stt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
from mycroft.util.log import LOG


class STT:
__metaclass__ = ABCMeta

class STT(metaclass=ABCMeta):
""" STT Base class, all STT backends derives from this one. """
def __init__(self):
config_core = Configuration.get()
self.lang = str(self.init_language(config_core))
Expand All @@ -50,33 +49,27 @@ def execute(self, audio, language=None):
pass


class TokenSTT(STT):
__metaclass__ = ABCMeta

class TokenSTT(STT, metaclass=ABCMeta):
def __init__(self):
super(TokenSTT, self).__init__()
self.token = str(self.credential.get("token"))


class GoogleJsonSTT(STT):
__metaclass__ = ABCMeta

class GoogleJsonSTT(STT, metaclass=ABCMeta):
def __init__(self):
super(GoogleJsonSTT, self).__init__()
self.json_credentials = json.dumps(self.credential.get("json"))


class BasicSTT(STT):
__metaclass__ = ABCMeta
class BasicSTT(STT, metaclass=ABCMeta):

def __init__(self):
super(BasicSTT, self).__init__()
self.username = str(self.credential.get("username"))
self.password = str(self.credential.get("password"))


class KeySTT(STT):
__metaclass__ = ABCMeta
class KeySTT(STT, metaclass=ABCMeta):

def __init__(self):
super(KeySTT, self).__init__()
Expand Down Expand Up @@ -169,11 +162,10 @@ def execute(self, audio, language=None):
return response.text


class StreamThread(Thread):
class StreamThread(Thread, metaclass=ABCMeta):
"""
ABC class to be used with StreamingSTT class implementations.
"""
__metaclass__ = ABCMeta

def __init__(self, queue, language):
super().__init__()
Expand All @@ -197,12 +189,10 @@ def handle_audio_stream(self, audio, language):
pass


class StreamingSTT(STT):
class StreamingSTT(STT, metaclass=ABCMeta):
"""
ABC class for threaded streaming STT implemenations.
"""
__metaclass__ = ABCMeta

def __init__(self):
super().__init__()
self.stream = None
Expand Down
8 changes: 2 additions & 6 deletions mycroft/tts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def stop(self):
self.clear_queue()


class TTS:
class TTS(metaclass=ABCMeta):
"""
TTS abstract class to be implemented by all TTS engines.
Expand All @@ -155,8 +155,6 @@ class TTS:
phonetic_spelling (bool): Whether to spell certain words phonetically
ssml_tags (list): Supported ssml properties. Ex. ['speak', 'prosody']
"""
__metaclass__ = ABCMeta

def __init__(self, lang, config, validator, audio_ext='wav',
phonetic_spelling=True, ssml_tags=None):
super(TTS, self).__init__()
Expand Down Expand Up @@ -395,15 +393,13 @@ def __del__(self):
self.playback.join()


class TTSValidator:
class TTSValidator(metaclass=ABCMeta):
"""
TTS Validator abstract class to be implemented by all TTS engines.
It exposes and implements ``validate(tts)`` function as a template to
validate the TTS engines.
"""
__metaclass__ = ABCMeta

def __init__(self, tts):
self.tts = tts

Expand Down

0 comments on commit e9879d9

Please sign in to comment.