Code according to PEP8 standard

This commit is contained in:
Paulus Schoutsen
2013-11-10 16:46:48 -08:00
parent 9c9b00c2d4
commit 483546a31d
8 changed files with 294 additions and 269 deletions

View File

@@ -10,6 +10,7 @@ import homeassistant.observers as observers
import homeassistant.actors as actors
import homeassistant.httpinterface as httpinterface
# pylint: disable=too-many-branches
def from_config_file(config_path):
""" Starts home assistant with all possible functionality
@@ -28,15 +29,15 @@ def from_config_file(config_path):
# Init observers
# Device scanner
if config.has_option('tomato', 'host') and \
config.has_option('tomato', 'username') and \
config.has_option('tomato', 'password') and \
config.has_option('tomato', 'http_id'):
config.has_option('tomato', 'username') and \
config.has_option('tomato', 'password') and \
config.has_option('tomato', 'http_id'):
device_scanner = observers.TomatoDeviceScanner(
config.get('tomato','host'),
config.get('tomato','username'),
config.get('tomato','password'),
config.get('tomato','http_id'))
config.get('tomato', 'host'),
config.get('tomato', 'username'),
config.get('tomato', 'password'),
config.get('tomato', 'http_id'))
if device_scanner.success_init:
statusses.append(("Device Scanner - Tomato", True))
@@ -49,28 +50,27 @@ def from_config_file(config_path):
else:
device_scanner = None
# Device Tracker
if device_scanner:
device_tracker = observers.DeviceTracker(eventbus, statemachine,
device_scanner)
device_tracker = observers.DeviceTracker(
eventbus, statemachine, device_scanner)
statusses.append(("Device Tracker", True))
else:
device_tracker = None
# Sun tracker
if config.has_option("common", "latitude") and \
config.has_option("common", "longitude"):
config.has_option("common", "longitude"):
statusses.append(("Weather - Ephem",
observers.track_sun(eventbus, statemachine,
config.get("common","latitude"),
config.get("common","longitude"))))
observers.track_sun(
eventbus, statemachine,
config.get("common", "latitude"),
config.get("common", "longitude"))))
# --------------------------
# Init actors
# Light control
if config.has_section("hue"):
@@ -84,7 +84,6 @@ def from_config_file(config_path):
else:
light_control = None
# Light trigger
if light_control:
actors.LightTrigger(eventbus, statemachine,
@@ -92,28 +91,26 @@ def from_config_file(config_path):
statusses.append(("Light Trigger", True))
if config.has_option("chromecast", "host"):
statusses.append(("Chromecast", actors.setup_chromecast(eventbus,
config.get("chromecast", "host"))))
statusses.append(("Chromecast",
actors.setup_chromecast(
eventbus, config.get("chromecast", "host"))))
if config.has_option("downloader", "download_dir"):
result = actors.setup_file_downloader(eventbus,
config.get("downloader", "download_dir"))
result = actors.setup_file_downloader(
eventbus, config.get("downloader", "download_dir"))
statusses.append(("Downloader", result))
statusses.append(("Webbrowser", actors.setup_webbrowser(eventbus)))
statusses.append(("Media Buttons", actors.setup_media_buttons(eventbus)))
# Init HTTP interface
if config.has_option("httpinterface", "api_password"):
httpinterface.HTTPInterface(eventbus, statemachine,
config.get("httpinterface","api_password"))
httpinterface.HTTPInterface(
eventbus, statemachine,
config.get("httpinterface", "api_password"))
statusses.append(("HTTPInterface", True))