Modify import of template and PEP257
This commit is contained in:
parent
213cc920d0
commit
582394bc3b
25 changed files with 152 additions and 182 deletions
|
@ -1,6 +1,4 @@
|
|||
"""
|
||||
homeassistant.components.notify
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides functionality to notify people.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
|
@ -13,7 +11,7 @@ import os
|
|||
import homeassistant.bootstrap as bootstrap
|
||||
from homeassistant.config import load_yaml_config_file
|
||||
from homeassistant.helpers import config_per_platform
|
||||
from homeassistant.util import template
|
||||
from homeassistant.helpers import template
|
||||
|
||||
from homeassistant.const import CONF_NAME
|
||||
|
||||
|
@ -35,7 +33,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def send_message(hass, message, title=None):
|
||||
""" Send a notification message. """
|
||||
"""Send a notification message."""
|
||||
data = {
|
||||
ATTR_MESSAGE: message
|
||||
}
|
||||
|
@ -47,14 +45,13 @@ def send_message(hass, message, title=None):
|
|||
|
||||
|
||||
def setup(hass, config):
|
||||
""" Sets up notify services. """
|
||||
"""Sets up notify services."""
|
||||
success = False
|
||||
|
||||
descriptions = load_yaml_config_file(
|
||||
os.path.join(os.path.dirname(__file__), 'services.yaml'))
|
||||
|
||||
for platform, p_config in config_per_platform(config, DOMAIN, _LOGGER):
|
||||
# get platform
|
||||
notify_implementation = bootstrap.prepare_setup_platform(
|
||||
hass, config, DOMAIN, platform)
|
||||
|
||||
|
@ -62,7 +59,6 @@ def setup(hass, config):
|
|||
_LOGGER.error("Unknown notification service specified.")
|
||||
continue
|
||||
|
||||
# create platform service
|
||||
notify_service = notify_implementation.get_service(hass, p_config)
|
||||
|
||||
if notify_service is None:
|
||||
|
@ -70,9 +66,8 @@ def setup(hass, config):
|
|||
platform)
|
||||
continue
|
||||
|
||||
# create service handler
|
||||
def notify_message(notify_service, call):
|
||||
""" Handle sending notification message service calls. """
|
||||
"""Handle sending notification message service calls."""
|
||||
message = call.data.get(ATTR_MESSAGE)
|
||||
|
||||
if message is None:
|
||||
|
@ -85,7 +80,6 @@ def setup(hass, config):
|
|||
|
||||
notify_service.send_message(message, title=title, target=target)
|
||||
|
||||
# register service
|
||||
service_call_handler = partial(notify_message, notify_service)
|
||||
service_notify = p_config.get(CONF_NAME, SERVICE_NOTIFY)
|
||||
hass.services.register(DOMAIN, service_notify, service_call_handler,
|
||||
|
@ -97,7 +91,7 @@ def setup(hass, config):
|
|||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class BaseNotificationService(object):
|
||||
""" Provides an ABC for notification services. """
|
||||
"""Provides an ABC for notification services."""
|
||||
|
||||
def send_message(self, message, **kwargs):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue