From 2e6388f6f4620674899f0efdb32a7d535d1328de Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 24 Aug 2020 01:14:40 +0200 Subject: [PATCH] ReadTheDocs fixes --- docs/source/events.rst | 1 - .../platypush/backend/stt.picovoice.rst | 5 - .../platypush/plugins/google.credentials.rst | 6 - .../platypush/plugins/media.search.local.rst | 6 - .../plugins/media.search.torrent.rst | 6 - .../plugins/media.search.youtube.rst | 6 - platypush/message/response/__init__.py | 21 +- platypush/message/response/bluetooth.py | 251 +++++++++--------- platypush/message/response/camera/android.py | 100 +++---- .../plugins/assistant/google/pushtotalk.py | 25 +- platypush/plugins/foursquare.py | 4 +- platypush/plugins/google/translate.py | 6 +- platypush/plugins/gpio/sensor/ltr559.py | 2 +- platypush/plugins/stt/deepspeech.py | 5 +- platypush/plugins/tensorflow/__init__.py | 6 +- platypush/plugins/zeroconf.py | 42 ++- platypush/plugins/zigbee/mqtt.py | 2 +- 17 files changed, 236 insertions(+), 258 deletions(-) delete mode 100644 docs/source/platypush/backend/stt.picovoice.rst delete mode 100644 docs/source/platypush/plugins/google.credentials.rst delete mode 100644 docs/source/platypush/plugins/media.search.local.rst delete mode 100644 docs/source/platypush/plugins/media.search.torrent.rst delete mode 100644 docs/source/platypush/plugins/media.search.youtube.rst diff --git a/docs/source/events.rst b/docs/source/events.rst index 2966d6ac..ee61e48d 100644 --- a/docs/source/events.rst +++ b/docs/source/events.rst @@ -6,7 +6,6 @@ Events :maxdepth: 2 :caption: Events: - platypush/events/.rst platypush/events/adafruit.rst platypush/events/alarm.rst platypush/events/application.rst diff --git a/docs/source/platypush/backend/stt.picovoice.rst b/docs/source/platypush/backend/stt.picovoice.rst deleted file mode 100644 index 20f7e34c..00000000 --- a/docs/source/platypush/backend/stt.picovoice.rst +++ /dev/null @@ -1,5 +0,0 @@ -``platypush.backend.stt.picovoice`` -=================================== - -.. automodule:: platypush.backend.stt.picovoice - :members: diff --git a/docs/source/platypush/plugins/google.credentials.rst b/docs/source/platypush/plugins/google.credentials.rst deleted file mode 100644 index 6e485869..00000000 --- a/docs/source/platypush/plugins/google.credentials.rst +++ /dev/null @@ -1,6 +0,0 @@ -``platypush.plugins.google.credentials`` -======================================== - -.. automodule:: platypush.plugins.google.credentials - :members: - diff --git a/docs/source/platypush/plugins/media.search.local.rst b/docs/source/platypush/plugins/media.search.local.rst deleted file mode 100644 index 07b4659e..00000000 --- a/docs/source/platypush/plugins/media.search.local.rst +++ /dev/null @@ -1,6 +0,0 @@ -``platypush.plugins.media.search.local`` -======================================== - -.. automodule:: platypush.plugins.media.search.local - :members: - diff --git a/docs/source/platypush/plugins/media.search.torrent.rst b/docs/source/platypush/plugins/media.search.torrent.rst deleted file mode 100644 index 6e7d6b2c..00000000 --- a/docs/source/platypush/plugins/media.search.torrent.rst +++ /dev/null @@ -1,6 +0,0 @@ -``platypush.plugins.media.search.torrent`` -========================================== - -.. automodule:: platypush.plugins.media.search.torrent - :members: - diff --git a/docs/source/platypush/plugins/media.search.youtube.rst b/docs/source/platypush/plugins/media.search.youtube.rst deleted file mode 100644 index 7bfa5a51..00000000 --- a/docs/source/platypush/plugins/media.search.youtube.rst +++ /dev/null @@ -1,6 +0,0 @@ -``platypush.plugins.media.search.youtube`` -========================================== - -.. automodule:: platypush.plugins.media.search.youtube - :members: - diff --git a/platypush/message/response/__init__.py b/platypush/message/response/__init__.py index 7488dc4b..588e45db 100644 --- a/platypush/message/response/__init__.py +++ b/platypush/message/response/__init__.py @@ -10,13 +10,18 @@ class Response(Message): def __init__(self, target=None, origin=None, id=None, output=None, errors=None, timestamp=None, disable_logging=False): """ - Params: - target -- Target [String] - origin -- Origin [String] - output -- Output [String] - errors -- Errors [List of strings or exceptions] - id -- Message ID this response refers to - timestamp -- Message timestamp [Float] + :param target: Target + :type target: str + :param origin: Origin + :type origin: str + :param output: Output + :type output: str + :param errors: Errors + :type errors: list + :param id: Message ID this response refers to + :type id: str + :param timestamp: Message timestamp + :type timestamp: float """ super().__init__(timestamp=timestamp) @@ -63,7 +68,7 @@ class Response(Message): def __str__(self): """ - Overrides the str() operator and converts + Overrides the ``str()`` operator and converts the message into a UTF-8 JSON string """ output = self.output if self.output is not None else { diff --git a/platypush/message/response/bluetooth.py b/platypush/message/response/bluetooth.py index bcc82fec..daa37a53 100644 --- a/platypush/message/response/bluetooth.py +++ b/platypush/message/response/bluetooth.py @@ -43,55 +43,58 @@ class BluetoothLookupNameResponse(BluetoothResponse): class BluetoothLookupServiceResponse(BluetoothResponse): """ - Example services response output:: + Example services response output: + + .. code-block:: json + + [ + { + "service-classes": [ + "1801" + ], + "profiles": [], + "name": "Service name #1", + "description": null, + "provider": null, + "service-id": null, + "protocol": "L2CAP", + "port": 31, + "host": "00:11:22:33:44:55" + }, + { + "service-classes": [ + "1800" + ], + "profiles": [], + "name": "Service name #2", + "description": null, + "provider": null, + "service-id": null, + "protocol": "L2CAP", + "port": 31, + "host": "00:11:22:33:44:56" + }, + { + "service-classes": [ + "1112", + "1203" + ], + "profiles": [ + [ + "1108", + 258 + ] + ], + "name": "Headset Gateway", + "description": null, + "provider": null, + "service-id": null, + "protocol": "RFCOMM", + "port": 2, + "host": "00:11:22:33:44:57" + } + ] - [ - { - "service-classes": [ - "1801" - ], - "profiles": [], - "name": "Service name #1", - "description": null, - "provider": null, - "service-id": null, - "protocol": "L2CAP", - "port": 31, - "host": "00:11:22:33:44:55" - }, - { - "service-classes": [ - "1800" - ], - "profiles": [], - "name": "Service name #2", - "description": null, - "provider": null, - "service-id": null, - "protocol": "L2CAP", - "port": 31, - "host": "00:11:22:33:44:56" - }, - { - "service-classes": [ - "1112", - "1203" - ], - "profiles": [ - [ - "1108", - 258 - ] - ], - "name": "Headset Gateway", - "description": null, - "provider": null, - "service-id": null, - "protocol": "RFCOMM", - "port": 2, - "host": "00:11:22:33:44:57" - } - ] """ def __init__(self, services: list, *args, **kwargs): self.services = services @@ -100,30 +103,32 @@ class BluetoothLookupServiceResponse(BluetoothResponse): class BluetoothDiscoverPrimaryResponse(BluetoothResponse): """ - Example services response output:: + Example services response output: - [ - { - "uuid": "00001800-0000-1000-8000-00805f9b34fb", - "start": 1, - "end": 7 - }, - { - "uuid": "00001801-0000-1000-8000-00805f9b34fb", - "start": 8, - "end": 8 - }, - { - "uuid": "0000fee7-0000-1000-8000-00805f9b34fb", - "start": 9, - "end": 16 - }, - { - "uuid": "cba20d00-224d-11e6-9fb8-0002a5d5c51b", - "start": 17, - "end": 65535 - } - ] + .. code-block:: json + + [ + { + "uuid": "00001800-0000-1000-8000-00805f9b34fb", + "start": 1, + "end": 7 + }, + { + "uuid": "00001801-0000-1000-8000-00805f9b34fb", + "start": 8, + "end": 8 + }, + { + "uuid": "0000fee7-0000-1000-8000-00805f9b34fb", + "start": 9, + "end": 16 + }, + { + "uuid": "cba20d00-224d-11e6-9fb8-0002a5d5c51b", + "start": 17, + "end": 65535 + } + ] """ def __init__(self, services: list, *args, **kwargs): @@ -133,58 +138,60 @@ class BluetoothDiscoverPrimaryResponse(BluetoothResponse): class BluetoothDiscoverCharacteristicsResponse(BluetoothResponse): """ - Example services response output:: + Example services response output: - [ - { - "uuid": "00002a00-0000-1000-8000-00805f9b34fb", - "handle": 2, - "properties": 10, - "value_handle": 3 - }, - { - "uuid": "00002a01-0000-1000-8000-00805f9b34fb", - "handle": 4, - "properties": 2, - "value_handle": 5 - }, - { - "uuid": "00002a04-0000-1000-8000-00805f9b34fb", - "handle": 6, - "properties": 2, - "value_handle": 7 - }, - { - "uuid": "0000fec8-0000-1000-8000-00805f9b34fb", - "handle": 10, - "properties": 32, - "value_handle": 11 - }, - { - "uuid": "0000fec7-0000-1000-8000-00805f9b34fb", - "handle": 13, - "properties": 8, - "value_handle": 14 - }, - { - "uuid": "0000fec9-0000-1000-8000-00805f9b34fb", - "handle": 15, - "properties": 2, - "value_handle": 16 - }, - { - "uuid": "cba20003-224d-11e6-9fb8-0002a5d5c51b", - "handle": 18, - "properties": 16, - "value_handle": 19 - }, - { - "uuid": "cba20002-224d-11e6-9fb8-0002a5d5c51b", - "handle": 21, - "properties": 12, - "value_handle": 22 - } - ] + .. code-block:: json + + [ + { + "uuid": "00002a00-0000-1000-8000-00805f9b34fb", + "handle": 2, + "properties": 10, + "value_handle": 3 + }, + { + "uuid": "00002a01-0000-1000-8000-00805f9b34fb", + "handle": 4, + "properties": 2, + "value_handle": 5 + }, + { + "uuid": "00002a04-0000-1000-8000-00805f9b34fb", + "handle": 6, + "properties": 2, + "value_handle": 7 + }, + { + "uuid": "0000fec8-0000-1000-8000-00805f9b34fb", + "handle": 10, + "properties": 32, + "value_handle": 11 + }, + { + "uuid": "0000fec7-0000-1000-8000-00805f9b34fb", + "handle": 13, + "properties": 8, + "value_handle": 14 + }, + { + "uuid": "0000fec9-0000-1000-8000-00805f9b34fb", + "handle": 15, + "properties": 2, + "value_handle": 16 + }, + { + "uuid": "cba20003-224d-11e6-9fb8-0002a5d5c51b", + "handle": 18, + "properties": 16, + "value_handle": 19 + }, + { + "uuid": "cba20002-224d-11e6-9fb8-0002a5d5c51b", + "handle": 21, + "properties": 12, + "value_handle": 22 + } + ] """ def __init__(self, characteristics: list, *args, **kwargs): diff --git a/platypush/message/response/camera/android.py b/platypush/message/response/camera/android.py index 5bf9446f..8becf538 100644 --- a/platypush/message/response/camera/android.py +++ b/platypush/message/response/camera/android.py @@ -5,58 +5,58 @@ from platypush.message.response.camera import CameraResponse class AndroidCameraStatusResponse(CameraResponse): """ - Sample response:: + Example response: - .. code-block:: json + .. code-block:: json - { - "stream_url": "https://192.168.1.30:8080/video", - "image_url": "https://192.168.1.30:8080/photo.jpg", - "audio_url": "https://192.168.1.30:8080/audio.wav", - "orientation": "landscape", - "idle": "off", - "audio_only": "off", - "overlay": "off", - "quality": "49", - "focus_homing": "off", - "ip_address": "192.168.1.30", - "motion_limit": "250", - "adet_limit": "200", - "night_vision": "off", - "night_vision_average": "2", - "night_vision_gain": "1.0", - "motion_detect": "off", - "motion_display": "off", - "video_chunk_len": "60", - "gps_active": "off", - "video_size": "1920x1080", - "mirror_flip": "none", - "ffc": "off", - "rtsp_video_formats": "", - "rtsp_audio_formats": "", - "video_connections": "0", - "audio_connections": "0", - "ivideon_streaming": "off", - "zoom": "100", - "crop_x": "50", - "crop_y": "50", - "coloreffect": "none", - "scenemode": "auto", - "focusmode": "continuous-video", - "whitebalance": "auto", - "flashmode": "off", - "antibanding": "off", - "torch": "off", - "focus_distance": "0.0", - "focal_length": "4.25", - "aperture": "1.7", - "filter_density": "0.0", - "exposure_ns": "9384", - "frame_duration": "33333333", - "iso": "100", - "manual_sensor": "off", - "photo_size": "1920x1080" - } + { + "stream_url": "https://192.168.1.30:8080/video", + "image_url": "https://192.168.1.30:8080/photo.jpg", + "audio_url": "https://192.168.1.30:8080/audio.wav", + "orientation": "landscape", + "idle": "off", + "audio_only": "off", + "overlay": "off", + "quality": "49", + "focus_homing": "off", + "ip_address": "192.168.1.30", + "motion_limit": "250", + "adet_limit": "200", + "night_vision": "off", + "night_vision_average": "2", + "night_vision_gain": "1.0", + "motion_detect": "off", + "motion_display": "off", + "video_chunk_len": "60", + "gps_active": "off", + "video_size": "1920x1080", + "mirror_flip": "none", + "ffc": "off", + "rtsp_video_formats": "", + "rtsp_audio_formats": "", + "video_connections": "0", + "audio_connections": "0", + "ivideon_streaming": "off", + "zoom": "100", + "crop_x": "50", + "crop_y": "50", + "coloreffect": "none", + "scenemode": "auto", + "focusmode": "continuous-video", + "whitebalance": "auto", + "flashmode": "off", + "antibanding": "off", + "torch": "off", + "focus_distance": "0.0", + "focal_length": "4.25", + "aperture": "1.7", + "filter_density": "0.0", + "exposure_ns": "9384", + "frame_duration": "33333333", + "iso": "100", + "manual_sensor": "off", + "photo_size": "1920x1080" + } """ diff --git a/platypush/plugins/assistant/google/pushtotalk.py b/platypush/plugins/assistant/google/pushtotalk.py index 4ec5a3c5..4e5f8345 100644 --- a/platypush/plugins/assistant/google/pushtotalk.py +++ b/platypush/plugins/assistant/google/pushtotalk.py @@ -34,6 +34,7 @@ class AssistantGooglePushtotalkPlugin(AssistantPlugin): * **tenacity** (``pip install tenacity``) * **google-assistant-sdk** (``pip install google-assistant-sdk[samples]``) + """ api_endpoint = 'embeddedassistant.googleapis.com' @@ -214,24 +215,20 @@ class AssistantGooglePushtotalkPlugin(AssistantPlugin): :param language: Language code override (default: default configured language). :param tts_plugin: Optional text-to-speech plugin to be used for rendering text. :param tts_args: Optional arguments for the TTS plugin say method. - :returns: A list of the interactions that happen within the conversation. ..code-block:: json - [ - { - "request": "request 1", - "response": "response 1" - - }, - - { - "request": "request 2", - "response": "response 2" - - } - ] + [ + { + "request": "request 1", + "response": "response 1" + }, + { + "request": "request 2", + "response": "response 2" + } + ] """ diff --git a/platypush/plugins/foursquare.py b/platypush/plugins/foursquare.py index 2e02e5bc..2a66cace 100644 --- a/platypush/plugins/foursquare.py +++ b/platypush/plugins/foursquare.py @@ -75,7 +75,7 @@ class FoursquarePlugin(Plugin): :param query: Search query (e.g. "coffee shops" or "restaurants"). :param limit: Maximum number of results. :param url: Venue URL to search. - :param categories: List of ``category IDs ``_ + :param categories: List of `category IDs `_ to be searched. :param radius: Search radius in meters. :param sw: South/west boundary box as a ``[latitude, longitude]`` pair. @@ -157,7 +157,7 @@ class FoursquarePlugin(Plugin): :param query: Search query (e.g. "coffee shops" or "restaurants"). The parameter has no effect if ``section`` is specified. :param limit: Maximum number of results. - :param categories: List of ``category IDs ``_ + :param categories: List of `category IDs `_ to be searched. :param radius: Search radius in meters. :param open_now: Filter by open/not open now. diff --git a/platypush/plugins/google/translate.py b/platypush/plugins/google/translate.py index 50d5eb3a..339a080b 100644 --- a/platypush/plugins/google/translate.py +++ b/platypush/plugins/google/translate.py @@ -16,13 +16,13 @@ class GoogleTranslatePlugin(Plugin): 1. Create a project on the `Google Cloud console `_ if you don't have one already. - 2. In the menu navigate to the _Artificial Intelligence_ section and select _Translations_ and enable the API. + 2. In the menu navigate to the *Artificial Intelligence* section and select *Translations* and enable the API. - 3. From the menu select _APIs & Services_ and create a service account. You can leave role and permissions + 3. From the menu select *APIs & Services* and create a service account. You can leave role and permissions empty. 4. Create a new private JSON key for the service account and download it. By default platypush will look for the - credentials file under ~/.credentials/platypush/google/translate.json. + credentials file under ``~/.credentials/platypush/google/translate.json``. Requires: diff --git a/platypush/plugins/gpio/sensor/ltr559.py b/platypush/plugins/gpio/sensor/ltr559.py index 80bf8d0b..ddf00527 100644 --- a/platypush/plugins/gpio/sensor/ltr559.py +++ b/platypush/plugins/gpio/sensor/ltr559.py @@ -22,7 +22,7 @@ class GpioSensorLtr559Plugin(GpioSensorPlugin): :returns: dict. Example: .. code-block:: python -: + output = { "light": 109.3543, # Lux "proximity": 103 # The higher the value, the nearest the object, within a ~5cm range diff --git a/platypush/plugins/stt/deepspeech.py b/platypush/plugins/stt/deepspeech.py index 10432567..afdcaf52 100644 --- a/platypush/plugins/stt/deepspeech.py +++ b/platypush/plugins/stt/deepspeech.py @@ -1,7 +1,6 @@ import os from typing import Optional, Union -import deepspeech import numpy as np import wave @@ -79,6 +78,7 @@ class SttDeepspeechPlugin(SttPlugin): :param block_duration: Duration of the acquired audio blocks (default: 1 second). """ + import deepspeech super().__init__(*args, **kwargs) self.model_file = os.path.abspath(os.path.expanduser(model_file)) self.lm_file = os.path.abspath(os.path.expanduser(lm_file)) @@ -89,7 +89,8 @@ class SttDeepspeechPlugin(SttPlugin): self._model: Optional[deepspeech.Model] = None self._context = None - def _get_model(self) -> deepspeech.Model: + def _get_model(self): + import deepspeech if not self._model: self._model = deepspeech.Model(self.model_file, self.beam_width) self._model.enableDecoderWithLM(self.lm_file, self.trie_file, self.lm_alpha, self.lm_beta) diff --git a/platypush/plugins/tensorflow/__init__.py b/platypush/plugins/tensorflow/__init__.py index 83a68f3f..5164d18c 100644 --- a/platypush/plugins/tensorflow/__init__.py +++ b/platypush/plugins/tensorflow/__init__.py @@ -719,9 +719,9 @@ class TensorflowPlugin(Plugin): The model will not be trained on this data. ``validation_data`` will override ``validation_split``. ``validation_data`` could be: - - tuple ``(x_val, y_val)`` of arrays/numpy arrays/tensors - - tuple ``(x_val, y_val, val_sample_weights)`` of Numpy arrays - - dataset + - tuple ``(x_val, y_val)`` of arrays/numpy arrays/tensors + - tuple ``(x_val, y_val, val_sample_weights)`` of Numpy arrays + - dataset For the first two cases, ``batch_size`` must be provided. For the last case, ``validation_steps`` could be provided. diff --git a/platypush/plugins/zeroconf.py b/platypush/plugins/zeroconf.py index d375bd3f..b92e1d45 100644 --- a/platypush/plugins/zeroconf.py +++ b/platypush/plugins/zeroconf.py @@ -86,32 +86,30 @@ class ZeroconfPlugin(Plugin): :param service: Service type (e.g. ``_http._tcp.local.``). :param timeout: Browser timeout in seconds (default: 5). Specify None for no timeout - in such case the discovery will loop forever and generate events upon service changes. - :return: A ``service_type -> [service_names]`` mapping. Example:: - + :return: A ``service_type -> [service_names]`` mapping. Example: .. code-block:: json - { - "host1._platypush-http._tcp.local.": { - "type": "_platypush-http._tcp.local.", - "name": "host1._platypush-http._tcp.local.", - "info": { - "addresses": ["192.168.1.11"], - "port": 8008, - "host_ttl": 120, - "other_ttl": 4500, - "priority": 0, - "properties": { - "name": "Platypush", - "vendor": "Platypush", - "version": "0.13.2" - }, - "server": "host1._platypush-http._tcp.local.", - "weight": 0 - } - }, - ... + { + "host1._platypush-http._tcp.local.": { + "type": "_platypush-http._tcp.local.", + "name": "host1._platypush-http._tcp.local.", + "info": { + "addresses": ["192.168.1.11"], + "port": 8008, + "host_ttl": 120, + "other_ttl": 4500, + "priority": 0, + "properties": { + "name": "Platypush", + "vendor": "Platypush", + "version": "0.13.2" + }, + "server": "host1._platypush-http._tcp.local.", + "weight": 0 + } } + } """ assert not self._discovery_in_progress, 'A discovery process is already running' diff --git a/platypush/plugins/zigbee/mqtt.py b/platypush/plugins/zigbee/mqtt.py index 6df4ebf8..ea758f42 100644 --- a/platypush/plugins/zigbee/mqtt.py +++ b/platypush/plugins/zigbee/mqtt.py @@ -19,7 +19,7 @@ class ZigbeeMqttPlugin(MqttPlugin): - Install `cc-tool `_ either from sources or from a package manager. - Connect the Zigbee to your PC/RaspberryPi in this way: USB -> CC debugger -> downloader cable -> CC2531 -> USB. - The debugger and the adapter should be connected _at the same time_. If the later ``cc-tool`` command throws up + The debugger and the adapter should be connected *at the same time*. If the later ``cc-tool`` command throws up an error, put the device in sync while connected by pressing the _Reset_ button on the debugger. - Check where the device is mapped. On Linux it will usually be ``/dev/ttyACM0``. - Download the latest `Z-Stack firmware `_ to your device.