Skip to content

Commit

Permalink
Version 1.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
sherif-fanous committed Aug 8, 2020
1 parent c0fd6c7 commit fc15a50
Show file tree
Hide file tree
Showing 60 changed files with 2,745 additions and 1,250 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Release History
===============
1.3.10 (2020-08-08)
-------------------
* Reformat code using Black instead of Autopep8

1.3.9 (2020-08-04)
------------------
* Migrate from PyCharm to VSCode
Expand Down
2 changes: 2 additions & 0 deletions pyecobee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@
try: # Python 2.X
from logging import NullHandler
except ImportError:

class NullHandler(logging.Handler):
def emit(self, record):
pass


logging.getLogger(__name__).addHandler(NullHandler())
100 changes: 72 additions & 28 deletions pyecobee/ecobee_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,33 @@ class EcobeeObject(object):
attribute_type_map = {}

def __repr__(self):
return '{0}('.format(self.__class__.__name__) + ', '.join(
['{0}={1!r}'.format(attribute_name[1:], getattr(self, attribute_name))
for attribute_name in self.slots()]) + ')'
return (
'{0}('.format(self.__class__.__name__)
+ ', '.join(
[
'{0}={1!r}'.format(
attribute_name[1:], getattr(self, attribute_name)
)
for attribute_name in self.slots()
]
)
+ ')'
)

def __str__(self):
return '{0}('.format(self.__class__.__name__) + ', '.join(
['{0}={1!s}'.format(type(self).attribute_name_map[attribute_name[1:]],
getattr(self, attribute_name))
for attribute_name in self.slots()]) + ')'
return (
'{0}('.format(self.__class__.__name__)
+ ', '.join(
[
'{0}={1!s}'.format(
type(self).attribute_name_map[attribute_name[1:]],
getattr(self, attribute_name),
)
for attribute_name in self.slots()
]
)
+ ')'
)

def pretty_format(self, indent=2, level=0, sort_attributes=True):
"""
Expand All @@ -34,44 +52,62 @@ def pretty_format(self, indent=2, level=0, sort_attributes=True):
level = level + 1

for (i, attribute_name) in enumerate(
sorted(self.slots()) if sort_attributes else self.slots()):
sorted(self.slots()) if sort_attributes else self.slots()
):
if i:
pretty_formatted.append(',\n')

if isinstance(getattr(self, attribute_name), list):
pretty_formatted.append('{0}{1}=[\n'.format(
' ' * (indent * level), self.attribute_name_map[attribute_name[1:]]))
pretty_formatted.append(
'{0}{1}=[\n'.format(
' ' * (indent * level),
self.attribute_name_map[attribute_name[1:]],
)
)
level = level + 1

for (j, list_entry) in enumerate(getattr(self, attribute_name)):
if j:
pretty_formatted.append(',\n')

if hasattr(list_entry, 'pretty_format'):
pretty_formatted.append('{0}{1}'.format(
' ' * (indent * level),
list_entry.pretty_format(indent, level, sort_attributes)))
pretty_formatted.append(
'{0}{1}'.format(
' ' * (indent * level),
list_entry.pretty_format(
indent, level, sort_attributes
),
)
)
else:
if isinstance(list_entry, list):
pretty_formatted.append('{0}[\n'.format(' ' * (indent * level)))
pretty_formatted.append(
'{0}[\n'.format(' ' * (indent * level))
)

level = level + 1

for (k, sub_list_entry) in enumerate(list_entry):
if k:
pretty_formatted.append(',\n')

pretty_formatted.append('{0}{1}'.format(' ' * (indent * level),
sub_list_entry))
pretty_formatted.append(
'{0}{1}'.format(
' ' * (indent * level), sub_list_entry
)
)

if list_entry:
pretty_formatted.append('\n')

level = level - 1
pretty_formatted.append('{0}]'.format(' ' * (indent * level)))
pretty_formatted.append(
'{0}]'.format(' ' * (indent * level))
)
else:
pretty_formatted.append('{0}{1}'.format(' ' * (indent * level),
list_entry))
pretty_formatted.append(
'{0}{1}'.format(' ' * (indent * level), list_entry)
)

if getattr(self, attribute_name):
pretty_formatted.append('\n')
Expand All @@ -82,20 +118,28 @@ def pretty_format(self, indent=2, level=0, sort_attributes=True):
pretty_formatted.append(' ' * (indent * level))

if hasattr(getattr(self, attribute_name), 'pretty_format'):
pretty_formatted.append('{0}={1!s}'.format(
self.attribute_name_map[attribute_name[1:]],
getattr(self, attribute_name).pretty_format(indent,
level,
sort_attributes)))
pretty_formatted.append(
'{0}={1!s}'.format(
self.attribute_name_map[attribute_name[1:]],
getattr(self, attribute_name).pretty_format(
indent, level, sort_attributes
),
)
)
else:
pretty_formatted.append('{0}={1!s}'.format(
self.attribute_name_map[attribute_name[1:]],
getattr(self, attribute_name)))
pretty_formatted.append(
'{0}={1!s}'.format(
self.attribute_name_map[attribute_name[1:]],
getattr(self, attribute_name),
)
)

level = level - 1
pretty_formatted.append('\n{0})'.format(' ' * (indent * level)))

return ''.join(pretty_formatted)

def slots(self):
return chain.from_iterable(getattr(cls, '__slots__', []) for cls in type(self).__mro__)
return chain.from_iterable(
getattr(cls, '__slots__', []) for cls in type(self).__mro__
)
6 changes: 4 additions & 2 deletions pyecobee/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class EcobeeException(Exception):
class EcobeeApiException(EcobeeException):
attribute_type_map = {
'status_code': 'six.text_type',
'status_message': 'six.text_type'}
'status_message': 'six.text_type',
}

def __init__(self, message, status_code, status_message):
super(EcobeeApiException, self).__init__(message)
Expand All @@ -26,7 +27,8 @@ class EcobeeAuthorizationException(EcobeeException):
attribute_type_map = {
'error': 'six.text_type',
'error_description': 'six.text_type',
'error_uri': 'six.text_type'}
'error_uri': 'six.text_type',
}

def __init__(self, message, error, error_description, error_uri):
super(EcobeeAuthorizationException, self).__init__(message)
Expand Down
28 changes: 21 additions & 7 deletions pyecobee/objects/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Action(EcobeeObject):
An __init__ argument with a default value of None has been generated
if the value of REQUIRED is "no".
"""

__slots__ = [
'_type',
'_send_alert',
Expand All @@ -31,7 +32,8 @@ class Action(EcobeeObject):
'_heat_adjust_temp',
'_cool_adjust_temp',
'_activate_relay',
'_activate_relay_open']
'_activate_relay_open',
]

attribute_name_map = {
'type': 'type',
Expand All @@ -52,7 +54,8 @@ class Action(EcobeeObject):
'activate_relay': 'activateRelay',
'activateRelay': 'activate_relay',
'activate_relay_open': 'activateRelayOpen',
'activateRelayOpen': 'activate_relay_open'}
'activateRelayOpen': 'activate_relay_open',
}

attribute_type_map = {
'type': 'six.text_type',
Expand All @@ -64,11 +67,22 @@ class Action(EcobeeObject):
'heat_adjust_temp': 'int',
'cool_adjust_temp': 'int',
'activate_relay': 'six.text_type',
'activate_relay_open': 'bool'}

def __init__(self, type_=None, send_alert=None, send_update=None, activation_delay=None,
deactivation_delay=None, min_action_duration=None, heat_adjust_temp=None,
cool_adjust_temp=None, activate_relay=None, activate_relay_open=None):
'activate_relay_open': 'bool',
}

def __init__(
self,
type_=None,
send_alert=None,
send_update=None,
activation_delay=None,
deactivation_delay=None,
min_action_duration=None,
heat_adjust_temp=None,
cool_adjust_temp=None,
activate_relay=None,
activate_relay_open=None,
):
"""
Construct an Action instance
"""
Expand Down
35 changes: 27 additions & 8 deletions pyecobee/objects/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Alert(EcobeeObject):
An __init__ argument with a default value of None has been generated
if the value of REQUIRED is "no".
"""

__slots__ = [
'_text',
'_acknowledge_ref',
Expand All @@ -37,7 +38,8 @@ class Alert(EcobeeObject):
'_acknowledgement',
'_remind_me_later',
'_thermostat_identifier',
'_notification_type']
'_notification_type',
]

attribute_name_map = {
'text': 'text',
Expand Down Expand Up @@ -65,7 +67,8 @@ class Alert(EcobeeObject):
'thermostat_identifier': 'thermostatIdentifier',
'thermostatIdentifier': 'thermostat_identifier',
'notification_type': 'notificationType',
'notificationType': 'notification_type'}
'notificationType': 'notification_type',
}

attribute_type_map = {
'text': 'six.text_type',
Expand All @@ -83,12 +86,28 @@ class Alert(EcobeeObject):
'acknowledgement': 'six.text_type',
'remind_me_later': 'bool',
'thermostat_identifier': 'six.text_type',
'notification_type': 'six.text_type'}

def __init__(self, text, acknowledge_ref=None, date=None, time=None, severity=None,
alert_number=None, alert_type=None, is_operator_alert=None, reminder=None,
show_idt=None, show_web=None, send_email=None, acknowledgement=None,
remind_me_later=None, thermostat_identifier=None, notification_type=None):
'notification_type': 'six.text_type',
}

def __init__(
self,
text,
acknowledge_ref=None,
date=None,
time=None,
severity=None,
alert_number=None,
alert_type=None,
is_operator_alert=None,
reminder=None,
show_idt=None,
show_web=None,
send_email=None,
acknowledgement=None,
remind_me_later=None,
thermostat_identifier=None,
notification_type=None,
):
"""
Construct an Alert instance
"""
Expand Down
22 changes: 16 additions & 6 deletions pyecobee/objects/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class Audio(EcobeeObject):
An __init__ argument with a default value of None has been generated
if the value of REQUIRED is "no".
"""

__slots__ = [
'_playback_volume',
'_microphone_enabled',
'_sound_alert_volume',
'_sound_tick_volume',
'_voice_engines']
'_voice_engines',
]

attribute_name_map = {
'playback_volume': 'playbackVolume',
Expand All @@ -38,17 +40,25 @@ class Audio(EcobeeObject):
'sound_tick_volume': 'soundTickVolume',
'soundTickVolume': 'sound_tick_volume',
'voice_engines': 'voiceEngines',
'voiceEngines': 'voice_engines'}
'voiceEngines': 'voice_engines',
}

attribute_type_map = {
'playback_volume': 'int',
'microphone_enabled': 'bool',
'sound_alert_volume': 'int',
'sound_tick_volume': 'int',
'voice_engines': 'List[VoiceEngine]'}

def __init__(self, playback_volume=None, microphone_enabled=None,
sound_alert_volume=None, sound_tick_volume=None, voice_engines=None):
'voice_engines': 'List[VoiceEngine]',
}

def __init__(
self,
playback_volume=None,
microphone_enabled=None,
sound_alert_volume=None,
sound_tick_volume=None,
voice_engines=None,
):
"""
Construct an Audio instance
"""
Expand Down
Loading

0 comments on commit fc15a50

Please sign in to comment.