From ec38ecbaf36940962cefd6d784396b33250de0cb Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 30 Jul 2018 23:18:01 +0200 Subject: [PATCH] More pylint fixes --- platypush/__init__.py | 2 +- platypush/backend/__init__.py | 2 +- .../backend/assistant/google/__init__.py | 38 +++++++++++++------ .../backend/assistant/google/pushtotalk.py | 27 +++++++++---- .../backend/assistant/snowboy/__init__.py | 8 ++-- 5 files changed, 52 insertions(+), 25 deletions(-) diff --git a/platypush/__init__.py b/platypush/__init__.py index 33da64c4..3d88d4ee 100644 --- a/platypush/__init__.py +++ b/platypush/__init__.py @@ -2,7 +2,7 @@ Platypush .. moduleauthor:: Fabio Manganiello -.. license:: MIT +.. license: MIT """ import argparse diff --git a/platypush/backend/__init__.py b/platypush/backend/__init__.py index d40b44f9..e714c800 100644 --- a/platypush/backend/__init__.py +++ b/platypush/backend/__init__.py @@ -1,6 +1,6 @@ """ .. moduleauthor:: Fabio Manganiello -.. license:: MIT +.. license: MIT """ import importlib diff --git a/platypush/backend/assistant/google/__init__.py b/platypush/backend/assistant/google/__init__.py index c1890208..07bbc27b 100644 --- a/platypush/backend/assistant/google/__init__.py +++ b/platypush/backend/assistant/google/__init__.py @@ -1,6 +1,6 @@ """ .. moduleauthor:: Fabio Manganiello -.. license:: MIT +.. license: MIT """ import json @@ -28,12 +28,18 @@ class AssistantGoogleBackend(Backend): Triggers: - * :class:`platypush.message.event.assistant.ConversationStartEvent` when a new conversation starts - * :class:`platypush.message.event.assistant.SpeechRecognizedEvent` when a new voice command is recognized - * :class:`platypush.message.event.assistant.NoResponse` when a conversation returned no response - * :class:`platypush.message.event.assistant.ResponseEvent` when the assistant is speaking a response - * :class:`platypush.message.event.assistant.ConversationTimeoutEvent` when a conversation times out - * :class:`platypush.message.event.assistant.ConversationEndEvent` when a new conversation ends + * :class:`platypush.message.event.assistant.ConversationStartEvent` \ + when a new conversation starts + * :class:`platypush.message.event.assistant.SpeechRecognizedEvent` \ + when a new voice command is recognized + * :class:`platypush.message.event.assistant.NoResponse` \ + when a conversation returned no response + * :class:`platypush.message.event.assistant.ResponseEvent` \ + when the assistant is speaking a response + * :class:`platypush.message.event.assistant.ConversationTimeoutEvent` \ + when a conversation times out + * :class:`platypush.message.event.assistant.ConversationEndEvent` \ + when a new conversation ends Requires: @@ -47,10 +53,15 @@ class AssistantGoogleBackend(Backend): 'google-oauthlib-tool', 'credentials.json'), device_model_id='Platypush', **kwargs): """ - :param credentials_file: Path to the Google OAuth credentials file (default: ~/.config/google-oauthlib-tool/credentials.json). See https://developers.google.com/assistant/sdk/guides/library/python/embed/install-sample#generate_credentials for how to get your own credentials file. + :param credentials_file: Path to the Google OAuth credentials file \ + (default: ~/.config/google-oauthlib-tool/credentials.json). \ + See https://developers.google.com/assistant/sdk/guides/library/python/embed/install-sample#generate_credentials \ + for instructions to get your own credentials file. + :type credentials_file: str - :param device_model_id: Device model ID to use for the assistant (default: Platypush) + :param device_model_id: Device model ID to use for the assistant \ + (default: Platypush) :type device_model_id: str """ @@ -60,8 +71,10 @@ class AssistantGoogleBackend(Backend): self.assistant = None with open(self.credentials_file, 'r') as f: - self.credentials = google.oauth2.credentials.Credentials(token=None, - **json.load(f)) + self.credentials = google.oauth2.credentials.Credentials( + token=None, + **json.load(f)) + self.logger.info('Initialized Google Assistant backend') def _process_event(self, event): @@ -76,7 +89,8 @@ class AssistantGoogleBackend(Backend): self.bus.post(ConversationTimeoutEvent()) elif event.type == EventType.ON_NO_RESPONSE: self.bus.post(NoResponseEvent()) - elif hasattr(EventType, 'ON_RENDER_RESPONSE') and event.type == EventType.ON_RENDER_RESPONSE: + elif hasattr(EventType, 'ON_RENDER_RESPONSE') and \ + event.type == EventType.ON_RENDER_RESPONSE: self.bus.post(ResponseEvent(response_text=event.args.get('text'))) elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED: phrase = event.args['text'].lower().strip() diff --git a/platypush/backend/assistant/google/pushtotalk.py b/platypush/backend/assistant/google/pushtotalk.py index 311e1a33..74d29863 100644 --- a/platypush/backend/assistant/google/pushtotalk.py +++ b/platypush/backend/assistant/google/pushtotalk.py @@ -1,6 +1,6 @@ """ .. moduleauthor:: Fabio Manganiello -.. license:: MIT +.. license: MIT """ import concurrent @@ -12,7 +12,8 @@ import grpc import google.auth.transport.grpc import google.auth.transport.requests import google.oauth2.credentials -from google.assistant.embedded.v1alpha2 import embedded_assistant_pb2, embedded_assistant_pb2_grpc +from google.assistant.embedded.v1alpha2 import embedded_assistant_pb2, \ + embedded_assistant_pb2_grpc import googlesamples.assistant.grpc.audio_helpers as audio_helpers import googlesamples.assistant.grpc.device_helpers as device_helpers @@ -36,9 +37,12 @@ class AssistantGooglePushtotalkBackend(Backend): Triggers: - * :class:`platypush.message.event.assistant.ConversationStartEvent` when a new conversation starts - * :class:`platypush.message.event.assistant.SpeechRecognizedEvent` when a new voice command is recognized - * :class:`platypush.message.event.assistant.ConversationEndEvent` when a new conversation ends + * :class:`platypush.message.event.assistant.ConversationStartEvent` \ + when a new conversation starts + * :class:`platypush.message.event.assistant.SpeechRecognizedEvent` \ + when a new voice command is recognized + * :class:`platypush.message.event.assistant.ConversationEndEvent` \ + when a new conversation ends Requires: @@ -66,10 +70,16 @@ class AssistantGooglePushtotalkBackend(Backend): conversation_start_fifo=os.path.join(os.path.sep, 'tmp', 'pushtotalk.fifo'), **kwargs): """ - :param credentials_file: Path to the Google OAuth credentials file (default: ~/.config/google-oauthlib-tool/credentials.json). See https://developers.google.com/assistant/sdk/guides/library/python/embed/install-sample#generate_credentials for how to get your own credentials file. + :param credentials_file: Path to the Google OAuth credentials file \ + (default: ~/.config/google-oauthlib-tool/credentials.json). \ + See https://developers.google.com/assistant/sdk/guides/library/python/embed/install-sample#generate_credentials \ + for instructions to get your own credentials file. :type credentials_file: str - :param device_config: Path to device_config.json. Register your device (see https://developers.google.com/assistant/sdk/guides/library/python/embed/register-device) and create a project, then run the pushtotalk.py script from googlesamples to create your device_config.json + :param device_config: Path to device_config.json. Register your device \ + (see https://developers.google.com/assistant/sdk/guides/library/python/embed/register-device) \ + and create a project, then run the pushtotalk.py script from \ + googlesamples to create your device_config.json :type device_config: str :param lang: Assistant language (default: en-US) @@ -197,7 +207,8 @@ class SampleAssistant: Args: device_model_id: identifier of the device model. device_id: identifier of the registered device instance. - conversation_stream(ConversationStream): audio stream for recording query and playing back assistant answer. + conversation_stream(ConversationStream): audio stream for recording \ + query and playing back assistant answer. channel: authorized gRPC channel for connection to the Google Assistant API. deadline_sec: gRPC deadline in seconds for Google Assistant API call. device_handler: callback for device actions. diff --git a/platypush/backend/assistant/snowboy/__init__.py b/platypush/backend/assistant/snowboy/__init__.py index e76f630e..6d63e226 100644 --- a/platypush/backend/assistant/snowboy/__init__.py +++ b/platypush/backend/assistant/snowboy/__init__.py @@ -1,6 +1,6 @@ """ .. moduleauthor:: Fabio Manganiello -.. license:: MIT +.. license: MIT """ import json @@ -24,7 +24,8 @@ class AssistantSnowboyBackend(Backend): Triggers: - * :class:`platypush.message.event.assistant.HotwordDetectedEvent` whenever the hotword has been detected + * :class:`platypush.message.event.assistant.HotwordDetectedEvent` \ + whenever the hotword has been detected Requires: @@ -34,7 +35,8 @@ class AssistantSnowboyBackend(Backend): def __init__(self, voice_model_file, hotword=None, sensitivity=0.5, audio_gain=1.0, **kwargs): """ - :param voice_model_file: Snowboy voice model file - see https://snowboy.kitt.ai/ + :param voice_model_file: Snowboy voice model file - \ + see https://snowboy.kitt.ai/ :type voice_model_file: str :param hotword: Name of the hotword