Update docstrings (#7374)

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstring

* Update docstrings

* Update docstrings

* Fix lint issues

* Update docstrings

* Revert changes in dict
This commit is contained in:
Fabian Affolter 2017-05-02 18:18:47 +02:00 committed by Paulus Schoutsen
parent 0e08925259
commit a4f1f6e724
340 changed files with 1533 additions and 1708 deletions

View file

@ -92,7 +92,7 @@ SONOS_SET_TIMER_SCHEMA = SONOS_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Sonos platform."""
"""Set up the Sonos platform."""
import soco
if DATA_SONOS not in hass.data:
@ -105,7 +105,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if discovery_info:
player = soco.SoCo(discovery_info.get('host'))
# if device allready exists by config
# if device already exists by config
if player.uid in [x.unique_id for x in hass.data[DATA_SONOS]]:
return
@ -132,18 +132,18 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
interface_addr=config.get(CONF_INTERFACE_ADDR))
if not players:
_LOGGER.warning('No Sonos speakers found.')
_LOGGER.warning("No Sonos speakers found")
return
hass.data[DATA_SONOS] = [SonosDevice(p) for p in players]
add_devices(hass.data[DATA_SONOS], True)
_LOGGER.info('Added %s Sonos speakers', len(players))
_LOGGER.info("Added %s Sonos speakers", len(players))
descriptions = load_yaml_config_file(
path.join(path.dirname(__file__), 'services.yaml'))
def service_handle(service):
"""Internal func for applying a service."""
"""Handle for services."""
entity_ids = service.data.get('entity_id')
if entity_ids:
@ -221,28 +221,28 @@ def _get_entity_from_soco(hass, soco):
for device in hass.data[DATA_SONOS]:
if soco == device.soco:
return device
raise ValueError("No entity for SoCo device!")
raise ValueError("No entity for SoCo device")
def soco_error(funct):
"""Decorator to catch soco exceptions."""
"""Catch soco exceptions."""
@ft.wraps(funct)
def wrapper(*args, **kwargs):
"""Wrapper for all soco exception."""
"""Wrap for all soco exception."""
from soco.exceptions import SoCoException
try:
return funct(*args, **kwargs)
except SoCoException as err:
_LOGGER.error("Error on %s with %s.", funct.__name__, err)
_LOGGER.error("Error on %s with %s", funct.__name__, err)
return wrapper
def soco_coordinator(funct):
"""Decorator to call funct on coordinator."""
"""Call function on coordinator."""
@ft.wraps(funct)
def wrapper(device, *args, **kwargs):
"""Wrapper for call to coordinator."""
"""Wrap for call to coordinator."""
if device.is_coordinator:
return funct(device, *args, **kwargs)
return funct(device.coordinator, *args, **kwargs)
@ -296,7 +296,7 @@ class SonosDevice(MediaPlayerDevice):
@property
def should_poll(self):
"""Polling needed."""
"""Return the polling state."""
return True
@property
@ -340,8 +340,7 @@ class SonosDevice(MediaPlayerDevice):
def _is_available(self):
try:
sock = socket.create_connection(
address=(self._player.ip_address, 1443),
timeout=3)
address=(self._player.ip_address, 1443), timeout=3)
sock.close()
return True
except socket.error: