Update/add docstrings (PEP257)

This commit is contained in:
Fabian Affolter committed 2016-02-23 06:23:04 +01:00
1 parent c64da761f1
commit 60d579af84
46 files changed
+407 -510

No files matched your search

+9 -12
View File
@@ -1,6 +1,4 @@
"""
homeassistant.components.sensor.arest
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The arest sensor will consume an exposed aREST API of a device.
For more details about this platform, please refer to the documentation at
@@ -27,8 +25,7 @@ CONF_MONITORED_VARIABLES = 'monitored_variables'
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Get the aREST sensor. """
"""Get the aREST sensor."""
resource = config.get(CONF_RESOURCE)
var_conf = config.get(CONF_MONITORED_VARIABLES)
pins = config.get('pins', None)
@@ -53,7 +50,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
arest = ArestData(resource)
def make_renderer(value_template):
""" Creates renderer based on variable_template value """
"""Creates renderer based on variable_template value."""
if value_template is None:
return lambda value: value
@@ -102,7 +99,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-instance-attributes, too-many-arguments
class ArestSensor(Entity):
""" Implements an aREST sensor for exposed variables. """
"""Implements an aREST sensor for exposed variables."""
def __init__(self, arest, resource, location, name, variable=None,
pin=None, unit_of_measurement=None, renderer=None):
@@ -125,17 +122,17 @@ class ArestSensor(Entity):
@property
def name(self):
""" The name of the sensor. """
"""The name of the sensor."""
return self._name
@property
def unit_of_measurement(self):
""" Unit the value is expressed in. """
"""Unit the value is expressed in."""
return self._unit_of_measurement
@property
def state(self):
""" Returns the state of the device. """
"""Returns the state of the sensor."""
values = self.arest.data
if 'error' in values:
@@ -147,13 +144,13 @@ class ArestSensor(Entity):
return value
def update(self):
""" Gets the latest data from aREST API. """
"""Gets the latest data from aREST API."""
self.arest.update()
# pylint: disable=too-few-public-methods
class ArestData(object):
""" Class for handling the data retrieval for variables. """
"""Class for handling the data retrieval for variables."""
def __init__(self, resource, pin=None):
self._resource = resource
@@ -162,7 +159,7 @@ class ArestData(object):
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
""" Gets the latest data from aREST device. """
"""Gets the latest data from aREST device."""
try:
if self._pin is None:
response = requests.get(self._resource, timeout=10)