Modify docstrings to match PEP257

This commit is contained in:
Fabian Affolter 2016-03-07 17:45:06 +01:00
parent 6ac9210919
commit 032f06e015
7 changed files with 27 additions and 39 deletions

View file

@ -121,7 +121,6 @@ def setup(hass, config):
class Camera(Entity): class Camera(Entity):
"""The base class for camera entities.""" """The base class for camera entities."""
def __init__(self): def __init__(self):
"""Initialize a camera.""" """Initialize a camera."""
self.is_streaming = False self.is_streaming = False

View file

@ -1,6 +1,4 @@
""" """
homeassistant.components.camera.bloomsky
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for a camera of a BloomSky weather station. Support for a camera of a BloomSky weather station.
For more details about this component, please refer to the documentation at For more details about this component, please refer to the documentation at
@ -18,7 +16,7 @@ DEPENDENCIES = ["bloomsky"]
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" set up access to BloomSky cameras """ """Setup access to BloomSky cameras."""
bloomsky = get_component('bloomsky') bloomsky = get_component('bloomsky')
for device in bloomsky.BLOOMSKY.devices.values(): for device in bloomsky.BLOOMSKY.devices.values():
add_devices_callback([BloomSkyCamera(bloomsky.BLOOMSKY, device)]) add_devices_callback([BloomSkyCamera(bloomsky.BLOOMSKY, device)])
@ -26,7 +24,6 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
class BloomSkyCamera(Camera): class BloomSkyCamera(Camera):
"""Represents the images published from the BloomSky's camera.""" """Represents the images published from the BloomSky's camera."""
def __init__(self, bs, device): def __init__(self, bs, device):
""" set up for access to the BloomSky camera images """ """ set up for access to the BloomSky camera images """
super(BloomSkyCamera, self).__init__() super(BloomSkyCamera, self).__init__()
@ -37,7 +34,7 @@ class BloomSkyCamera(Camera):
self._last_url = "" self._last_url = ""
# _last_image will store images as they are downloaded so that the # _last_image will store images as they are downloaded so that the
# frequent updates in home-assistant don't keep poking the server # frequent updates in home-assistant don't keep poking the server
# to download the same image over and over # to download the same image over and over.
self._last_image = "" self._last_image = ""
self._logger = logging.getLogger(__name__) self._logger = logging.getLogger(__name__)
@ -46,7 +43,7 @@ class BloomSkyCamera(Camera):
try: try:
self._url = self._bloomsky.devices[self._id]["Data"]["ImageURL"] self._url = self._bloomsky.devices[self._id]["Data"]["ImageURL"]
self._bloomsky.refresh_devices() self._bloomsky.refresh_devices()
# if the url hasn't changed then the image hasn't changed # If the URL hasn't changed then the image hasn't changed.
if self._url != self._last_url: if self._url != self._last_url:
response = requests.get(self._url, timeout=10) response = requests.get(self._url, timeout=10)
self._last_url = self._url self._last_url = self._url

View file

@ -19,7 +19,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class DemoCamera(Camera): class DemoCamera(Camera):
"""A Demo camera.""" """A Demo camera."""
def __init__(self, name): def __init__(self, name):
super().__init__() super().__init__()
self._name = name self._name = name

View file

@ -1,6 +1,4 @@
""" """
homeassistant.components.camera.foscam
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This component provides basic support for Foscam IP cameras. This component provides basic support for Foscam IP cameras.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
@ -18,7 +16,7 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Adds a Foscam IP Camera. """ """Setup a Foscam IP Camera."""
if not validate_config({DOMAIN: config}, if not validate_config({DOMAIN: config},
{DOMAIN: ['username', 'password', 'ip']}, _LOGGER): {DOMAIN: ['username', 'password', 'ip']}, _LOGGER):
return None return None
@ -29,7 +27,6 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
class FoscamCamera(Camera): class FoscamCamera(Camera):
"""An implementation of a Foscam IP camera.""" """An implementation of a Foscam IP camera."""
def __init__(self, device_info): def __init__(self, device_info):
super(FoscamCamera, self).__init__() super(FoscamCamera, self).__init__()
@ -49,7 +46,6 @@ class FoscamCamera(Camera):
def camera_image(self): def camera_image(self):
"""Return a still image reponse from the camera.""" """Return a still image reponse from the camera."""
# Send the request to snap a picture and return raw jpg data # Send the request to snap a picture and return raw jpg data
response = requests.get(self._snap_picture_url) response = requests.get(self._snap_picture_url)
@ -57,5 +53,5 @@ class FoscamCamera(Camera):
@property @property
def name(self): def name(self):
""" Return the name of this device. """ """Return the name of this camera."""
return self._name return self._name

View file

@ -1,6 +1,4 @@
""" """
homeassistant.components.camera.generic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for IP Cameras. Support for IP Cameras.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
@ -19,7 +17,7 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Adds a generic IP Camera. """ """Setup a generic IP Camera."""
if not validate_config({DOMAIN: config}, {DOMAIN: ['still_image_url']}, if not validate_config({DOMAIN: config}, {DOMAIN: ['still_image_url']},
_LOGGER): _LOGGER):
return None return None
@ -32,7 +30,6 @@ class GenericCamera(Camera):
""" """
A generic implementation of an IP camera that is reachable over a URL. A generic implementation of an IP camera that is reachable over a URL.
""" """
def __init__(self, device_info): def __init__(self, device_info):
super().__init__() super().__init__()
self._name = device_info.get('name', 'Generic Camera') self._name = device_info.get('name', 'Generic Camera')

View file

@ -1,6 +1,4 @@
""" """
homeassistant.components.camera.mjpeg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for IP Cameras. Support for IP Cameras.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
@ -23,7 +21,7 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Adds a mjpeg IP Camera. """ """Setup a MJPEG IP Camera."""
if not validate_config({DOMAIN: config}, {DOMAIN: ['mjpeg_url']}, if not validate_config({DOMAIN: config}, {DOMAIN: ['mjpeg_url']},
_LOGGER): _LOGGER):
return None return None
@ -45,7 +43,7 @@ class MjpegCamera(Camera):
self._mjpeg_url = device_info['mjpeg_url'] self._mjpeg_url = device_info['mjpeg_url']
def camera_stream(self): def camera_stream(self):
""" Return a mjpeg stream image response directly from the camera. """ """Return a MJPEG stream image response directly from the camera."""
if self._username and self._password: if self._username and self._password:
return requests.get(self._mjpeg_url, return requests.get(self._mjpeg_url,
auth=HTTPBasicAuth(self._username, auth=HTTPBasicAuth(self._username,
@ -57,7 +55,6 @@ class MjpegCamera(Camera):
def camera_image(self): def camera_image(self):
"""Return a still image response from the camera.""" """Return a still image response from the camera."""
def process_response(response): def process_response(response):
"""Take in a response object, return the jpg from it.""" """Take in a response object, return the jpg from it."""
data = b'' data = b''
@ -88,5 +85,5 @@ class MjpegCamera(Camera):
@property @property
def name(self): def name(self):
""" Return the name of this device. """ """Return the name of this camera."""
return self._name return self._name

View file

@ -1,6 +1,4 @@
""" """
homeassistant.components.camera.uvc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Support for Ubiquiti's UVC cameras. Support for Ubiquiti's UVC cameras.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
@ -61,7 +59,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class UnifiVideoCamera(Camera): class UnifiVideoCamera(Camera):
"""A Ubiquiti Unifi Video Camera.""" """A Ubiquiti Unifi Video Camera."""
def __init__(self, nvr, uuid, name): def __init__(self, nvr, uuid, name):
super(UnifiVideoCamera, self).__init__() super(UnifiVideoCamera, self).__init__()
self._nvr = nvr self._nvr = nvr
@ -73,23 +70,28 @@ class UnifiVideoCamera(Camera):
@property @property
def name(self): def name(self):
"""Return the name of this camera."""
return self._name return self._name
@property @property
def is_recording(self): def is_recording(self):
"""Return true if the camera is recording."""
caminfo = self._nvr.get_camera(self._uuid) caminfo = self._nvr.get_camera(self._uuid)
return caminfo['recordingSettings']['fullTimeRecordEnabled'] return caminfo['recordingSettings']['fullTimeRecordEnabled']
@property @property
def brand(self): def brand(self):
"""Return the brand of this camera."""
return 'Ubiquiti' return 'Ubiquiti'
@property @property
def model(self): def model(self):
"""Return the model of this camera."""
caminfo = self._nvr.get_camera(self._uuid) caminfo = self._nvr.get_camera(self._uuid)
return caminfo['model'] return caminfo['model']
def _login(self): def _login(self):
"""Login to the camera."""
from uvcclient import camera as uvc_camera from uvcclient import camera as uvc_camera
from uvcclient import store as uvc_store from uvcclient import store as uvc_store
@ -131,6 +133,7 @@ class UnifiVideoCamera(Camera):
return True return True
def camera_image(self): def camera_image(self):
"""Return the image of this camera."""
from uvcclient import camera as uvc_camera from uvcclient import camera as uvc_camera
if not self._camera: if not self._camera:
if not self._login(): if not self._login():