Modify import of template and PEP257

This commit is contained in:
Fabian Affolter committed 2016-02-23 21:19:22 +01:00
1 parent 213cc920d0
commit 582394bc3b
25 files changed
+152 -182

No files matched your search

+10 -12
View File
@@ -1,7 +1,5 @@
"""
components.alexa
~~~~~~~~~~~~~~~~
Component to offer a service end point for an Alexa skill.
Support for Alexa skill service end point.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/alexa/
@@ -11,7 +9,7 @@ import logging
from homeassistant.const import HTTP_OK, HTTP_UNPROCESSABLE_ENTITY
from homeassistant.helpers.service import call_from_config
from homeassistant.util import template
from homeassistant.helpers import template
DOMAIN = 'alexa'
DEPENDENCIES = ['http']
@@ -28,7 +26,7 @@ CONF_ACTION = 'action'
def setup(hass, config):
""" Activate Alexa component. """
"""Activate Alexa component."""
_CONFIG.update(config[DOMAIN].get(CONF_INTENTS, {}))
hass.http.register_path('POST', API_ENDPOINT, _handle_alexa, True)
@@ -37,7 +35,7 @@ def setup(hass, config):
def _handle_alexa(handler, path_match, data):
""" Handle Alexa. """
"""Handle Alexa."""
_LOGGER.debug('Received Alexa request: %s', data)
req = data.get('request')
@@ -99,19 +97,19 @@ def _handle_alexa(handler, path_match, data):
class SpeechType(enum.Enum):
""" Alexa speech types. """
"""Alexa speech types."""
plaintext = "PlainText"
ssml = "SSML"
class CardType(enum.Enum):
""" Alexa card types. """
"""Alexa card types."""
simple = "Simple"
link_account = "LinkAccount"
class AlexaResponse(object):
""" Helps generating the response for Alexa. """
"""Helps generating the response for Alexa."""
def __init__(self, hass, intent=None):
self.hass = hass
@@ -154,7 +152,7 @@ class AlexaResponse(object):
}
def add_reprompt(self, speech_type, text):
""" Add repromopt if user does not answer. """
"""Add reprompt if user does not answer."""
assert self.reprompt is None
key = 'ssml' if speech_type == SpeechType.ssml else 'text'
@@ -165,7 +163,7 @@ class AlexaResponse(object):
}
def as_dict(self):
""" Returns response in an Alexa valid dict. """
"""Returns response in an Alexa valid dict."""
response = {
'shouldEndSession': self.should_end_session
}
@@ -188,5 +186,5 @@ class AlexaResponse(object):
}
def _render(self, template_string):
""" Render a response, adding data from intent if available. """
"""Render a response, adding data from intent if available."""
return template.render(self.hass, template_string, self.variables)