From 652f059d6a85a152023d16782e1996dbc4e7e346 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 8 Mar 2016 11:46:32 +0100 Subject: [PATCH] Fix PEP257 issues --- homeassistant/components/notify/__init__.py | 8 ++++---- .../components/notify/command_line.py | 13 +++++------- homeassistant/components/notify/demo.py | 8 ++++---- homeassistant/components/notify/file.py | 13 +++++------- .../components/notify/free_mobile.py | 12 +++++------ .../components/notify/googlevoice.py | 11 ++++------ homeassistant/components/notify/instapush.py | 12 ++++------- homeassistant/components/notify/nma.py | 11 ++++------ homeassistant/components/notify/pushbullet.py | 14 ++++++------- homeassistant/components/notify/pushetta.py | 14 ++++--------- homeassistant/components/notify/pushover.py | 10 ++++------ homeassistant/components/notify/rest.py | 11 ++++------ homeassistant/components/notify/sendgrid.py | 9 ++++----- homeassistant/components/notify/slack.py | 11 ++++------ homeassistant/components/notify/smtp.py | 14 +++++-------- homeassistant/components/notify/syslog.py | 7 +++---- homeassistant/components/notify/telegram.py | 9 ++++----- homeassistant/components/notify/twitter.py | 10 ++++------ homeassistant/components/notify/xmpp.py | 20 +++++++++---------- 19 files changed, 86 insertions(+), 131 deletions(-) diff --git a/homeassistant/components/notify/__init__.py b/homeassistant/components/notify/__init__.py index 2b1ece959ac..85086aa15cc 100644 --- a/homeassistant/components/notify/__init__.py +++ b/homeassistant/components/notify/__init__.py @@ -45,7 +45,7 @@ def send_message(hass, message, title=None): def setup(hass, config): - """Sets up notify services.""" + """Setup the notify services.""" success = False descriptions = load_yaml_config_file( @@ -91,11 +91,11 @@ def setup(hass, config): # pylint: disable=too-few-public-methods class BaseNotificationService(object): - """Provides an ABC for notification services.""" + """An abstract class for notification services.""" def send_message(self, message, **kwargs): - """ - Send a message. + """Send a message. + kwargs can contain ATTR_TITLE to specify a title. """ raise NotImplementedError diff --git a/homeassistant/components/notify/command_line.py b/homeassistant/components/notify/command_line.py index 4852c7312d1..df77560c22b 100644 --- a/homeassistant/components/notify/command_line.py +++ b/homeassistant/components/notify/command_line.py @@ -1,7 +1,5 @@ """ -homeassistant.components.notify.command_line -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -command_line notification service. +Support for command line notification services. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/notify.command_line/ @@ -16,8 +14,7 @@ _LOGGER = logging.getLogger(__name__) def get_service(hass, config): - """ Get the Command Line notification service. """ - + """Get the Command Line notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['command']}, _LOGGER): @@ -30,14 +27,14 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class CommandLineNotificationService(BaseNotificationService): - """ Implements notification service for the Command Line service. """ + """Implement the notification service for the Command Line service.""" def __init__(self, command): + """Initialize the service.""" self.command = command def send_message(self, message="", **kwargs): - """ Send a message to a command_line. """ - + """Send a message to a command line.""" try: proc = subprocess.Popen(self.command, universal_newlines=True, stdin=subprocess.PIPE, shell=True) diff --git a/homeassistant/components/notify/demo.py b/homeassistant/components/notify/demo.py index d4fbf08f7b9..c051bce020d 100644 --- a/homeassistant/components/notify/demo.py +++ b/homeassistant/components/notify/demo.py @@ -16,13 +16,13 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class DemoNotificationService(BaseNotificationService): - """Implements demo notification service.""" + """Implement demo notification service.""" + def __init__(self, hass): + """Initialize the service.""" self.hass = hass def send_message(self, message="", **kwargs): - """ Send a message to a user. """ - + """Send a message to a user.""" title = kwargs.get(ATTR_TITLE) - self.hass.bus.fire(EVENT_NOTIFY, {"title": title, "message": message}) diff --git a/homeassistant/components/notify/file.py b/homeassistant/components/notify/file.py index 5f9befa9510..f9b186e59ad 100644 --- a/homeassistant/components/notify/file.py +++ b/homeassistant/components/notify/file.py @@ -1,7 +1,5 @@ """ -homeassistant.components.notify.file -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -File notification service. +Support for file notification. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/notify.file/ @@ -18,8 +16,7 @@ _LOGGER = logging.getLogger(__name__) def get_service(hass, config): - """ Get the file notification service. """ - + """Get the file notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['filename', 'timestamp']}, @@ -34,15 +31,15 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class FileNotificationService(BaseNotificationService): - """ Implements notification service for the File service. """ + """Implement the notification service for the File service.""" def __init__(self, hass, filename, add_timestamp): + """Initialize the service.""" self.filepath = os.path.join(hass.config.config_dir, filename) self.add_timestamp = add_timestamp def send_message(self, message="", **kwargs): - """ Send a message to a file. """ - + """Send a message to a file.""" with open(self.filepath, 'a') as file: if os.stat(self.filepath).st_size == 0: title = '{} notifications (Log started: {})\n{}\n'.format( diff --git a/homeassistant/components/notify/free_mobile.py b/homeassistant/components/notify/free_mobile.py index 10ba96e2e73..e12cc5893b8 100644 --- a/homeassistant/components/notify/free_mobile.py +++ b/homeassistant/components/notify/free_mobile.py @@ -1,7 +1,5 @@ """ -homeassistant.components.notify.free_mobile -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Free Mobile SMS platform for notify component. +Support for thr Free Mobile SMS platform. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/notify.free_mobile/ @@ -17,8 +15,7 @@ REQUIREMENTS = ['freesms==0.1.0'] def get_service(hass, config): - """ Get the Free Mobile SMS notification service. """ - + """Get the Free Mobile SMS notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: [CONF_USERNAME, CONF_ACCESS_TOKEN]}, @@ -31,14 +28,15 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class FreeSMSNotificationService(BaseNotificationService): - """ Implements notification service for the Free Mobile SMS service. """ + """Implement a notification service for the Free Mobile SMS service.""" def __init__(self, username, access_token): + """Initialize the service.""" from freesms import FreeClient self.free_client = FreeClient(username, access_token) def send_message(self, message="", **kwargs): - """ Send a message to the Free Mobile user cell. """ + """Send a message to the Free Mobile user cell.""" resp = self.free_client.send_sms(message) if resp.status_code == 400: diff --git a/homeassistant/components/notify/googlevoice.py b/homeassistant/components/notify/googlevoice.py index c66ec5e99a3..021496fa00b 100644 --- a/homeassistant/components/notify/googlevoice.py +++ b/homeassistant/components/notify/googlevoice.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.googlevoice -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Google Voice SMS platform for notify component. For more details about this platform, please refer to the documentation at @@ -20,8 +18,7 @@ REQUIREMENTS = ['https://github.com/w1ll1am23/pygooglevoice-sms/archive/' def get_service(hass, config): - """ Get the Google Voice SMS notification service. """ - + """Get the Google Voice SMS notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: [CONF_USERNAME, CONF_PASSWORD]}, @@ -34,17 +31,17 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class GoogleVoiceSMSNotificationService(BaseNotificationService): - """ Implements notification service for the Google Voice SMS service. """ + """Implement the notification service for the Google Voice SMS service.""" def __init__(self, username, password): + """Initialize the service.""" from googlevoicesms import Voice self.voice = Voice() self.username = username self.password = password def send_message(self, message="", **kwargs): - """ Send SMS to specified target user cell. """ - + """Send SMS to specified target user cell.""" targets = kwargs.get(ATTR_TARGET) if not targets: diff --git a/homeassistant/components/notify/instapush.py b/homeassistant/components/notify/instapush.py index d3dd05d7e54..028afb32468 100644 --- a/homeassistant/components/notify/instapush.py +++ b/homeassistant/components/notify/instapush.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.instapush -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Instapush notification service. For more details about this platform, please refer to the documentation at @@ -21,8 +19,7 @@ _RESOURCE = 'https://api.instapush.im/v1/' def get_service(hass, config): - """ Get the instapush notification service. """ - + """Get the instapush notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: [CONF_API_KEY, 'app_secret', @@ -58,9 +55,10 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class InstapushNotificationService(BaseNotificationService): - """ Implements notification service for Instapush. """ + """Implement the notification service for Instapush.""" def __init__(self, api_key, app_secret, event, tracker): + """Initialize the service.""" self._api_key = api_key self._app_secret = app_secret self._event = event @@ -71,10 +69,8 @@ class InstapushNotificationService(BaseNotificationService): 'Content-Type': 'application/json'} def send_message(self, message="", **kwargs): - """ Send a message to a user. """ - + """Send a message to a user.""" title = kwargs.get(ATTR_TITLE) - data = {"event": self._event, "trackers": {self._tracker: title + " : " + message}} diff --git a/homeassistant/components/notify/nma.py b/homeassistant/components/notify/nma.py index 5133bbf287d..f37f5ca8bd0 100644 --- a/homeassistant/components/notify/nma.py +++ b/homeassistant/components/notify/nma.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.nma -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NMA (Notify My Android) notification service. For more details about this platform, please refer to the documentation at @@ -21,8 +19,7 @@ _RESOURCE = 'https://www.notifymyandroid.com/publicapi/' def get_service(hass, config): - """ Get the NMA notification service. """ - + """Get the NMA notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: [CONF_API_KEY]}, _LOGGER): @@ -41,14 +38,14 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class NmaNotificationService(BaseNotificationService): - """ Implements notification service for NMA. """ + """Implement the notification service for NMA.""" def __init__(self, api_key): + """Initialize the service.""" self._api_key = api_key def send_message(self, message="", **kwargs): - """ Send a message to a user. """ - + """Send a message to a user.""" data = { "apikey": self._api_key, "application": 'home-assistant', diff --git a/homeassistant/components/notify/pushbullet.py b/homeassistant/components/notify/pushbullet.py index c7fbf5478e3..1baee8e5287 100644 --- a/homeassistant/components/notify/pushbullet.py +++ b/homeassistant/components/notify/pushbullet.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.pushbullet -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PushBullet platform for notify component. For more details about this platform, please refer to the documentation at @@ -18,7 +16,7 @@ REQUIREMENTS = ['pushbullet.py==0.9.0'] # pylint: disable=unused-argument def get_service(hass, config): - """ Get the PushBullet notification service. """ + """Get the PushBullet notification service.""" from pushbullet import PushBullet from pushbullet import InvalidKeyError @@ -39,16 +37,16 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class PushBulletNotificationService(BaseNotificationService): - """ Implements notification service for Pushbullet. """ + """Implement the notification service for Pushbullet.""" def __init__(self, pb): + """Initialize the service.""" self.pushbullet = pb self.pbtargets = {} self.refresh() def refresh(self): - """ - Refresh devices, contacts, etc + """Refresh devices, contacts, etc. pbtargets stores all targets available from this pushbullet instance into a dict. These are PB objects!. It sacrifices a bit of memory @@ -67,8 +65,8 @@ class PushBulletNotificationService(BaseNotificationService): } def send_message(self, message=None, **kwargs): - """ - Send a message to a specified target. + """Send a message to a specified target. + If no target specified, a 'normal' push will be sent to all devices linked to the PB account. Email is special, these are assumed to always exist. We use a special diff --git a/homeassistant/components/notify/pushetta.py b/homeassistant/components/notify/pushetta.py index d2c797d2fd7..234c8978452 100644 --- a/homeassistant/components/notify/pushetta.py +++ b/homeassistant/components/notify/pushetta.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.pushetta -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Pushetta platform for notify component. For more details about this platform, please refer to the documentation at @@ -19,8 +17,7 @@ REQUIREMENTS = ['pushetta==1.0.15'] def get_service(hass, config): - """ Get the Pushetta notification service. """ - + """Get the Pushetta notification service.""" from pushetta import Pushetta, exceptions if not validate_config({DOMAIN: config}, @@ -44,20 +41,17 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class PushettaNotificationService(BaseNotificationService): - """ Implements notification service for Pushetta. """ + """Implement the notification service for Pushetta.""" def __init__(self, api_key, channel_name): - + """Initialize the service.""" from pushetta import Pushetta - self._api_key = api_key self._channel_name = channel_name self.pushetta = Pushetta(self._api_key) def send_message(self, message="", **kwargs): - """ Send a message to a user. """ - + """Send a message to a user.""" title = kwargs.get(ATTR_TITLE) - self.pushetta.pushMessage(self._channel_name, "{} {}".format(title, message)) diff --git a/homeassistant/components/notify/pushover.py b/homeassistant/components/notify/pushover.py index 6eaa1b91643..b202f38fa7c 100644 --- a/homeassistant/components/notify/pushover.py +++ b/homeassistant/components/notify/pushover.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.pushover -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Pushover platform for notify component. For more details about this platform, please refer to the documentation at @@ -19,8 +17,7 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-variable def get_service(hass, config): - """ Get the pushover notification service. """ - + """Get the Pushover notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['user_key', CONF_API_KEY]}, _LOGGER): @@ -40,9 +37,10 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class PushoverNotificationService(BaseNotificationService): - """ Implements notification service for Pushover. """ + """Implement the notification service for Pushover.""" def __init__(self, user_key, api_token): + """Initialize the service.""" from pushover import Client self._user_key = user_key self._api_token = api_token @@ -50,7 +48,7 @@ class PushoverNotificationService(BaseNotificationService): self._user_key, api_token=self._api_token) def send_message(self, message="", **kwargs): - """ Send a message to a user. """ + """Send a message to a user.""" from pushover import RequestError try: diff --git a/homeassistant/components/notify/rest.py b/homeassistant/components/notify/rest.py index 7f5582fd0fe..4c2c069a4b9 100644 --- a/homeassistant/components/notify/rest.py +++ b/homeassistant/components/notify/rest.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.rest -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ REST platform for notify component. For more details about this platform, please refer to the documentation at @@ -23,8 +21,7 @@ DEFAULT_TARGET_PARAM_NAME = None def get_service(hass, config): - """ Get the REST notification service. """ - + """Get the REST notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['resource', ]}, _LOGGER): @@ -45,10 +42,11 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods, too-many-arguments class RestNotificationService(BaseNotificationService): - """ Implements notification service for REST. """ + """Implement the notification service for REST.""" def __init__(self, resource, method, message_param_name, title_param_name, target_param_name): + """Initialize the service.""" self._resource = resource self._method = method.upper() self._message_param_name = message_param_name @@ -56,8 +54,7 @@ class RestNotificationService(BaseNotificationService): self._target_param_name = target_param_name def send_message(self, message="", **kwargs): - """ Send a message to a user. """ - + """Send a message to a user.""" data = { self._message_param_name: message } diff --git a/homeassistant/components/notify/sendgrid.py b/homeassistant/components/notify/sendgrid.py index f56bbb59d3e..ac3fc3deaab 100644 --- a/homeassistant/components/notify/sendgrid.py +++ b/homeassistant/components/notify/sendgrid.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.sendgrid -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SendGrid notification service. For more details about this platform, please refer to the documentation at @@ -17,7 +15,7 @@ _LOGGER = logging.getLogger(__name__) def get_service(hass, config): - """ Get the SendGrid notification service """ + """Get the SendGrid notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['api_key', 'sender', 'recipient']}, _LOGGER): @@ -31,9 +29,10 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class SendgridNotificationService(BaseNotificationService): - """ Implements the notification service for email via Sendgrid. """ + """Implement the notification service for email via Sendgrid.""" def __init__(self, api_key, sender, recipient): + """Initialize the service.""" self.api_key = api_key self.sender = sender self.recipient = recipient @@ -42,7 +41,7 @@ class SendgridNotificationService(BaseNotificationService): self._sg = SendGridClient(self.api_key) def send_message(self, message='', **kwargs): - """ Send an email to a user via SendGrid. """ + """Send an email to a user via SendGrid.""" subject = kwargs.get(ATTR_TITLE) from sendgrid import Mail diff --git a/homeassistant/components/notify/slack.py b/homeassistant/components/notify/slack.py index 75034aebb32..48c1578efe3 100644 --- a/homeassistant/components/notify/slack.py +++ b/homeassistant/components/notify/slack.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.slack -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slack platform for notify component. For more details about this platform, please refer to the documentation at @@ -18,7 +16,7 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-variable def get_service(hass, config): - """ Get the slack notification service. """ + """Get the Slack notification service.""" import slacker if not validate_config({DOMAIN: config}, @@ -39,22 +37,21 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class SlackNotificationService(BaseNotificationService): - """ Implements notification service for Slack. """ + """Implement the notification service for Slack.""" def __init__(self, default_channel, api_token): + """Initialize the service.""" from slacker import Slacker - self._default_channel = default_channel self._api_token = api_token self.slack = Slacker(self._api_token) self.slack.auth.test() def send_message(self, message="", **kwargs): - """ Send a message to a user. """ + """Send a message to a user.""" import slacker channel = kwargs.get('channel', self._default_channel) - try: self.slack.chat.post_message(channel, message) except slacker.Error: diff --git a/homeassistant/components/notify/smtp.py b/homeassistant/components/notify/smtp.py index 8ee48ed9644..7664753f2ee 100644 --- a/homeassistant/components/notify/smtp.py +++ b/homeassistant/components/notify/smtp.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.smtp -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mail (SMTP) notification service. For more details about this platform, please refer to the documentation at @@ -18,8 +16,7 @@ _LOGGER = logging.getLogger(__name__) def get_service(hass, config): - """ Get the mail notification service. """ - + """Get the mail notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['recipient']}, _LOGGER): @@ -74,11 +71,12 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods, too-many-instance-attributes class MailNotificationService(BaseNotificationService): - """ Implements notification service for E-Mail messages. """ + """Implement the notification service for E-Mail messages.""" # pylint: disable=too-many-arguments def __init__(self, server, port, sender, starttls, username, password, recipient, debug): + """Initialize the service.""" self._server = server self._port = port self._sender = sender @@ -90,8 +88,7 @@ class MailNotificationService(BaseNotificationService): self.tries = 2 def connect(self): - """ Connect/Authenticate to SMTP Server """ - + """Connect/authenticate to SMTP Server.""" mail = smtplib.SMTP(self._server, self._port, timeout=5) mail.set_debuglevel(self.debug) mail.ehlo_or_helo_if_needed() @@ -103,8 +100,7 @@ class MailNotificationService(BaseNotificationService): return mail def send_message(self, message="", **kwargs): - """ Send a message to a user. """ - + """Send a message to a user.""" mail = self.connect() subject = kwargs.get(ATTR_TITLE) diff --git a/homeassistant/components/notify/syslog.py b/homeassistant/components/notify/syslog.py index b568ce7d41c..381a92394c3 100644 --- a/homeassistant/components/notify/syslog.py +++ b/homeassistant/components/notify/syslog.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.syslog -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Syslog notification service. For more details about this platform, please refer to the documentation at @@ -69,16 +67,17 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class SyslogNotificationService(BaseNotificationService): - """ Implements syslog notification service. """ + """Implement the syslog notification service.""" # pylint: disable=too-many-arguments def __init__(self, facility, option, priority): + """Initialize the service.""" self._facility = facility self._option = option self._priority = priority def send_message(self, message="", **kwargs): - """ Send a message to a user. """ + """Send a message to a user.""" import syslog title = kwargs.get(ATTR_TITLE) diff --git a/homeassistant/components/notify/telegram.py b/homeassistant/components/notify/telegram.py index 727ba578765..a5c46376ef1 100644 --- a/homeassistant/components/notify/telegram.py +++ b/homeassistant/components/notify/telegram.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.telegram -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Telegram platform for notify component. For more details about this platform, please refer to the documentation at @@ -20,7 +18,7 @@ REQUIREMENTS = ['python-telegram-bot==3.2.0'] def get_service(hass, config): - """ Get the Telegram notification service. """ + """Get the Telegram notification service.""" import telegram if not validate_config({DOMAIN: config}, @@ -41,9 +39,10 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class TelegramNotificationService(BaseNotificationService): - """ Implements notification service for Telegram. """ + """Implement the notification service for Telegram.""" def __init__(self, api_key, chat_id): + """Initialize the service.""" import telegram self._api_key = api_key @@ -51,7 +50,7 @@ class TelegramNotificationService(BaseNotificationService): self.bot = telegram.Bot(token=self._api_key) def send_message(self, message="", **kwargs): - """ Send a message to a user. """ + """Send a message to a user.""" import telegram title = kwargs.get(ATTR_TITLE) diff --git a/homeassistant/components/notify/twitter.py b/homeassistant/components/notify/twitter.py index e0770381d72..45c54fd88de 100644 --- a/homeassistant/components/notify/twitter.py +++ b/homeassistant/components/notify/twitter.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.twitter -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Twitter platform for notify component. For more details about this platform, please refer to the documentation at @@ -21,8 +19,7 @@ CONF_ACCESS_TOKEN_SECRET = "access_token_secret" def get_service(hass, config): - """ Get the Twitter notification service. """ - + """Get the Twitter notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: [CONF_CONSUMER_KEY, CONF_CONSUMER_SECRET, CONF_ACCESS_TOKEN, @@ -38,16 +35,17 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class TwitterNotificationService(BaseNotificationService): - """ Implements notification service for the Twitter service. """ + """Implement notification service for the Twitter service.""" def __init__(self, consumer_key, consumer_secret, access_token_key, access_token_secret): + """Initialize the service.""" from TwitterAPI import TwitterAPI self.api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret) def send_message(self, message="", **kwargs): - """ Tweet some message. """ + """Tweet some message.""" resp = self.api.request('statuses/update', {'status': message}) if resp.status_code != 200: import json diff --git a/homeassistant/components/notify/xmpp.py b/homeassistant/components/notify/xmpp.py index 9b3bec0b195..2e609b120da 100644 --- a/homeassistant/components/notify/xmpp.py +++ b/homeassistant/components/notify/xmpp.py @@ -1,6 +1,4 @@ """ -homeassistant.components.notify.xmpp -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Jabber (XMPP) notification service. For more details about this platform, please refer to the documentation at @@ -18,8 +16,7 @@ _LOGGER = logging.getLogger(__name__) def get_service(hass, config): - """ Get the Jabber (XMPP) notification service. """ - + """Get the Jabber (XMPP) notification service.""" if not validate_config({DOMAIN: config}, {DOMAIN: ['sender', 'password', 'recipient']}, _LOGGER): @@ -32,16 +29,16 @@ def get_service(hass, config): # pylint: disable=too-few-public-methods class XmppNotificationService(BaseNotificationService): - """ Implements notification service for Jabber (XMPP). """ + """Implement the notification service for Jabber (XMPP).""" def __init__(self, sender, password, recipient): + """Initialize the service.""" self._sender = sender self._password = password self._recipient = recipient def send_message(self, message="", **kwargs): - """ Send a message to a user. """ - + """Send a message to a user.""" title = kwargs.get(ATTR_TITLE) data = "{}: {}".format(title, message) if title else message @@ -50,13 +47,14 @@ class XmppNotificationService(BaseNotificationService): def send_message(sender, password, recipient, message): - """ Send a message over XMPP. """ + """Send a message over XMPP.""" import sleekxmpp class SendNotificationBot(sleekxmpp.ClientXMPP): - """ Service for sending Jabber (XMPP) messages. """ + """Service for sending Jabber (XMPP) messages.""" def __init__(self): + """Initialize the Jabber Bot.""" super(SendNotificationBot, self).__init__(sender, password) logging.basicConfig(level=logging.ERROR) @@ -69,14 +67,14 @@ def send_message(sender, password, recipient, message): self.process() def start(self, event): - """ Starts the communication and sends the message. """ + """Start the communication and sends the message.""" self.send_presence() self.get_roster() self.send_message(mto=recipient, mbody=message, mtype='chat') self.disconnect(wait=True) def check_credentials(self, event): - """" Disconnect from the server if credentials are invalid. """ + """"Disconnect from the server if credentials are invalid.""" self.disconnect() SendNotificationBot()