diff --git a/homeassistant/__init__.py b/homeassistant/__init__.py index 05f86fd5b88..892b9b8f92e 100644 --- a/homeassistant/__init__.py +++ b/homeassistant/__init__.py @@ -42,21 +42,31 @@ def start_home_assistant(eventbus): break def datetime_to_str(dattim): - """ Converts datetime to a string format. """ + """ Converts datetime to a string format. + + @rtype : str + """ return dattim.strftime(DATE_STR_FORMAT) def str_to_datetime(dt_str): - """ Converts a string to a datetime object. """ + """ Converts a string to a datetime object. + + @rtype: datetime + """ return datetime.strptime(dt_str, DATE_STR_FORMAT) def ensure_list(parameter): - """ Wraps parameter in a list if it is not one and returns it. """ + """ Wraps parameter in a list if it is not one and returns it. + + @rtype : list + """ return parameter if isinstance(parameter, list) else [parameter] def matcher(subject, pattern): """ Returns True if subject matches the pattern. Pattern is either a list of allowed subjects or a '*'. + @rtype : bool """ return '*' in pattern or subject in pattern @@ -100,7 +110,7 @@ def track_time_change(eventbus, action, """ Listens for matching time_changed events. """ now = str_to_datetime(event.data['now']) - if (point_in_time and now > point_in_time) or \ + if (point_in_time and now > point_in_time) or \ (not point_in_time and \ matcher(now.year, year) and \ matcher(now.month, month) and \ diff --git a/homeassistant/actors.py b/homeassistant/actors.py index d6328a8fda9..4201c898124 100644 --- a/homeassistant/actors.py +++ b/homeassistant/actors.py @@ -97,11 +97,11 @@ class LightTrigger(object): start_point = self._time_for_light_before_sun_set() - def turn_on(light_id): + def turn_on(light): """ Lambda can keep track of function parameters but not local parameters. If we put the lambda directly in the below statement only the last light would be turned on.. """ - return lambda now: self._turn_light_on_before_sunset(light_id) + return lambda now: self._turn_light_on_before_sunset(light) for index, light_id in enumerate(self.light_control.light_ids): ha.track_time_change(self.eventbus, turn_on(light_id), @@ -146,7 +146,7 @@ class LightTrigger(object): # if someone would be home? # Check this by seeing if current time is later then the point # in time when we would start putting the lights on. - elif now > start_point and now < self._next_sun_setting(): + elif start_point < now < self._next_sun_setting(): # Check for every light if it would be on if someone was home # when the fading in started and turn it on if so diff --git a/homeassistant/httpinterface.py b/homeassistant/httpinterface.py index e2898922cfe..1b299a49b0b 100644 --- a/homeassistant/httpinterface.py +++ b/homeassistant/httpinterface.py @@ -157,8 +157,8 @@ class RequestHandler(BaseHTTPRequestHandler): '_handle_fire_event'), # Statis files - ('GET', re.compile(r'/static/(?P[a-zA-Z\._\-0-9\/]+)'), - '_handle_get_static') + ('GET', re.compile(r'/static/(?P[a-zA-Z\._\-0-9/]+)'), + '_handle_get_static') ] use_json = False diff --git a/homeassistant/observers.py b/homeassistant/observers.py index 833f0f7b1d9..5144fff893d 100644 --- a/homeassistant/observers.py +++ b/homeassistant/observers.py @@ -49,7 +49,7 @@ def track_sun(eventbus, statemachine, latitude, longitude): try: import ephem except ImportError: - logger.exception(("TrackSun:Error while importing dependency ephem.")) + logger.exception("TrackSun:Error while importing dependency ephem.") return False sun = ephem.Sun() # pylint: disable=no-member diff --git a/homeassistant/test.py b/homeassistant/test.py index 674ff8ebae6..40d3f09af84 100644 --- a/homeassistant/test.py +++ b/homeassistant/test.py @@ -35,7 +35,7 @@ def ensure_homeassistant_started(): core['statemachine'] = ha.StateMachine(core['eventbus']) core['eventbus'].listen('test_event', len) - core['statemachine'].set_state('test','a_state') + core['statemachine'].set_state('test', 'a_state') hah.HTTPInterface(core['eventbus'], core['statemachine'], API_PASSWORD)