From 2609852d6e82eff04df3a9c083377c0e09545e31 Mon Sep 17 00:00:00 2001
From: Fabian Affolter <fabian@affolter-engineering.ch>
Date: Fri, 26 Feb 2016 23:52:54 +0100
Subject: [PATCH] Modify docstrings to match PEP257

---
 homeassistant/components/browser.py          | 11 ++++-----
 homeassistant/components/graphite.py         | 25 ++++++++------------
 homeassistant/components/influxdb.py         | 14 ++++-------
 homeassistant/components/mqtt_eventstream.py | 25 ++++++++------------
 homeassistant/components/splunk.py           | 12 ++++------
 homeassistant/components/statsd.py           |  9 +++----
 6 files changed, 36 insertions(+), 60 deletions(-)

diff --git a/homeassistant/components/browser.py b/homeassistant/components/browser.py
index 88548e2a1b3..d171e4b5901 100644
--- a/homeassistant/components/browser.py
+++ b/homeassistant/components/browser.py
@@ -1,21 +1,18 @@
 """
-homeassistant.components.browser
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Provides functionality to launch a webbrowser on the host machine.
+Provides functionality to launch a web browser on the host machine.
 
 For more details about this component, please refer to the documentation at
 https://home-assistant.io/components/browser/
 """
 
 DOMAIN = "browser"
-
 SERVICE_BROWSE_URL = "browse_url"
 
 
 def setup(hass, config):
-    """ Listen for browse_url events and open
-        the url in the default webbrowser. """
-
+    """
+    Listen for browse_url events and open the url in the default web browser.
+    """
     import webbrowser
 
     hass.services.register(DOMAIN, SERVICE_BROWSE_URL,
diff --git a/homeassistant/components/graphite.py b/homeassistant/components/graphite.py
index 49ac6690edf..4e726f06bb5 100644
--- a/homeassistant/components/graphite.py
+++ b/homeassistant/components/graphite.py
@@ -1,8 +1,6 @@
 """
-homeassistant.components.graphite
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Component that records all events and state changes and feeds the data to
-a graphite installation.
+a Graphite installation.
 
 For more details about this component, please refer to the documentation at
 https://home-assistant.io/components/graphite/
@@ -22,7 +20,7 @@ _LOGGER = logging.getLogger(__name__)
 
 
 def setup(hass, config):
-    """ Setup graphite feeder. """
+    """Setup the Graphite feeder."""
     graphite_config = config.get('graphite', {})
     host = graphite_config.get('host', 'localhost')
     prefix = graphite_config.get('prefix', 'ha')
@@ -37,14 +35,13 @@ def setup(hass, config):
 
 
 class GraphiteFeeder(threading.Thread):
-    """ Feeds data to graphite. """
+    """Feeds data to Graphite."""
     def __init__(self, hass, host, port, prefix):
         super(GraphiteFeeder, self).__init__(daemon=True)
         self._hass = hass
         self._host = host
         self._port = port
-        # rstrip any trailing dots in case they think they
-        # need it
+        # rstrip any trailing dots in case they think they need it
         self._prefix = prefix.rstrip('.')
         self._queue = queue.Queue()
         self._quit_object = object()
@@ -59,23 +56,18 @@ class GraphiteFeeder(threading.Thread):
                       self._host, self._port)
 
     def start_listen(self, event):
-        """ Start event-processing thread. """
+        """Start event-processing thread."""
         _LOGGER.debug('Event processing thread started')
         self._we_started = True
         self.start()
 
     def shutdown(self, event):
-        """ Tell the thread that we are done.
-
-        This does not block because there is nothing to
-        clean up (and no penalty for killing in-process
-        connections to graphite.
-        """
+        """Signal shutdown of processing event."""
         _LOGGER.debug('Event processing signaled exit')
         self._queue.put(self._quit_object)
 
     def event_listener(self, event):
-        """ Queue an event for processing. """
+        """Queue an event for processing."""
         if self.is_alive() or not self._we_started:
             _LOGGER.debug('Received event')
             self._queue.put(event)
@@ -84,6 +76,7 @@ class GraphiteFeeder(threading.Thread):
                           'queuing event!')
 
     def _send_to_graphite(self, data):
+        """Send data to Graphite."""
         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         sock.settimeout(10)
         sock.connect((self._host, self._port))
@@ -92,6 +85,7 @@ class GraphiteFeeder(threading.Thread):
         sock.close()
 
     def _report_attributes(self, entity_id, new_state):
+        """Report the attributes."""
         now = time.time()
         things = dict(new_state.attributes)
         try:
@@ -114,6 +108,7 @@ class GraphiteFeeder(threading.Thread):
             _LOGGER.exception('Failed to send data to graphite')
 
     def run(self):
+        """Run the process to export the data."""
         while True:
             event = self._queue.get()
             if event == self._quit_object:
diff --git a/homeassistant/components/influxdb.py b/homeassistant/components/influxdb.py
index 3e19fd8692a..749dd4bd097 100644
--- a/homeassistant/components/influxdb.py
+++ b/homeassistant/components/influxdb.py
@@ -1,7 +1,5 @@
 """
-homeassistant.components.influxdb
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-InfluxDB component which allows you to send data to an Influx database.
+A component which allows you to send data to an Influx database.
 
 For more details about this component, please refer to the documentation at
 https://home-assistant.io/components/influxdb/
@@ -36,8 +34,7 @@ CONF_VERIFY_SSL = 'verify_ssl'
 
 
 def setup(hass, config):
-    """ Setup the InfluxDB component. """
-
+    """Setup the InfluxDB component."""
     from influxdb import InfluxDBClient, exceptions
 
     if not validate_config(config, {DOMAIN: ['host',
@@ -63,13 +60,12 @@ def setup(hass, config):
         influx.query("select * from /.*/ LIMIT 1;")
     except exceptions.InfluxDBClientError as exc:
         _LOGGER.error("Database host is not accessible due to '%s', please "
-                      "check your entries in the configuration file and that"
-                      " the database exists and is READ/WRITE.", exc)
+                      "check your entries in the configuration file and that "
+                      "the database exists and is READ/WRITE.", exc)
         return False
 
     def influx_event_listener(event):
-        """ Listen for new messages on the bus and sends them to Influx. """
-
+        """Listen for new messages on the bus and sends them to Influx."""
         state = event.data.get('new_state')
         if state is None or state.state in (STATE_UNKNOWN, ''):
             return
diff --git a/homeassistant/components/mqtt_eventstream.py b/homeassistant/components/mqtt_eventstream.py
index 0574c07ebf9..fe4c8c546ca 100644
--- a/homeassistant/components/mqtt_eventstream.py
+++ b/homeassistant/components/mqtt_eventstream.py
@@ -1,10 +1,8 @@
 """
-homeassistant.components.mqtt_eventstream
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Connect two Home Assistant instances via MQTT..
+Connect two Home Assistant instances via MQTT.
 
 For more details about this component, please refer to the documentation at
-https://home-assistant.io/components/mqtt_eventstream.html
+https://home-assistant.io/components/mqtt_eventstream/
 """
 import json
 
@@ -17,21 +15,18 @@ from homeassistant.const import (
 from homeassistant.core import EventOrigin, State
 from homeassistant.remote import JSONEncoder
 
-# The domain of your component. Should be equal to the name of your component
 DOMAIN = "mqtt_eventstream"
-
-# List of component names (string) your component depends upon
 DEPENDENCIES = ['mqtt']
 
 
 def setup(hass, config):
-    """ Setup th MQTT eventstream component. """
+    """Setup th MQTT eventstream component."""
     mqtt = loader.get_component('mqtt')
     pub_topic = config[DOMAIN].get('publish_topic', None)
     sub_topic = config[DOMAIN].get('subscribe_topic', None)
 
     def _event_publisher(event):
-        """ Handle events by publishing them on the MQTT queue. """
+        """Handle events by publishing them on the MQTT queue."""
         if event.origin != EventOrigin.local:
             return
         if event.event_type == EVENT_TIME_CHANGED:
@@ -61,15 +56,15 @@ def setup(hass, config):
         msg = json.dumps(event_info, cls=JSONEncoder)
         mqtt.publish(hass, pub_topic, msg)
 
-    # Only listen for local events if you are going to publish them
+    # Only listen for local events if you are going to publish them.
     if pub_topic:
         hass.bus.listen(MATCH_ALL, _event_publisher)
 
-    # Process events from a remote server that are received on a queue
+    # Process events from a remote server that are received on a queue.
     def _event_receiver(topic, payload, qos):
         """
-        Receive events published by the other HA instance and fire
-        them on this hass instance.
+        Receive events published by the other HA instance and fire them on
+        this hass instance.
         """
         event = json.loads(payload)
         event_type = event.get('event_type')
@@ -92,10 +87,10 @@ def setup(hass, config):
             origin=EventOrigin.remote
         )
 
-    # Only subscribe if you specified a topic
+    # Only subscribe if you specified a topic.
     if sub_topic:
         mqtt.subscribe(hass, sub_topic, _event_receiver)
 
     hass.states.set('{domain}.initialized'.format(domain=DOMAIN), True)
-    # return boolean to indicate that initialization was successful
+
     return True
diff --git a/homeassistant/components/splunk.py b/homeassistant/components/splunk.py
index 6db577865eb..584031dfd80 100644
--- a/homeassistant/components/splunk.py
+++ b/homeassistant/components/splunk.py
@@ -1,8 +1,6 @@
 """
-homeassistant.components.splunk
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Splunk component which allows you to send data to an Splunk instance
-utilizing the HTTP Event Collector.
+A component which allows you to send data to an Splunk instance utilizing the
+HTTP Event Collector.
 
 For more details about this component, please refer to the documentation at
 https://home-assistant.io/components/splunk/
@@ -33,8 +31,7 @@ CONF_SSL = 'SSL'
 
 
 def setup(hass, config):
-    """ Setup the Splunk component. """
-
+    """Setup the Splunk component."""
     if not validate_config(config, {DOMAIN: ['token']}, _LOGGER):
         _LOGGER.error("You must include the token for your HTTP "
                       "Event Collector input in Splunk.")
@@ -55,8 +52,7 @@ def setup(hass, config):
     headers = {'Authorization': 'Splunk ' + token}
 
     def splunk_event_listener(event):
-        """ Listen for new messages on the bus and sends them to Splunk. """
-
+        """Listen for new messages on the bus and sends them to Splunk."""
         state = event.data.get('new_state')
 
         if state is None:
diff --git a/homeassistant/components/statsd.py b/homeassistant/components/statsd.py
index 6dbf1ae8bda..6de3f6805b7 100644
--- a/homeassistant/components/statsd.py
+++ b/homeassistant/components/statsd.py
@@ -1,7 +1,5 @@
 """
-homeassistant.components.statsd
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-StatsD component which allows you to send data to many backends.
+A component which allows you to send data to StatsD.
 
 For more details about this component, please refer to the documentation at
 https://home-assistant.io/components/statsd/
@@ -31,8 +29,7 @@ CONF_RATE = 'rate'
 
 
 def setup(hass, config):
-    """ Setup the StatsD component. """
-
+    """Setup the StatsD component."""
     from statsd.compat import NUM_TYPES
     import statsd
 
@@ -53,7 +50,7 @@ def setup(hass, config):
     meter = statsd.Gauge(prefix, statsd_connection)
 
     def statsd_event_listener(event):
-        """ Listen for new messages on the bus and sends them to StatsD. """
+        """Listen for new messages on the bus and sends them to StatsD."""
 
         state = event.data.get('new_state')
 
-- 
GitLab