jcarbaugh / python-roku

Screw remotes. Control your Roku with Python.
https://pypi.python.org/pypi/roku
BSD 3-Clause "New" or "Revised" License
288 stars 94 forks source link

Define `__dir__` to contain `COMMANDS` and `SENSORS` #76

Closed ronnie-llamado closed 1 year ago

ronnie-llamado commented 2 years ago

Update Roku.__dir__ to contain COMMANDS and SENSORS. This is helpful when running python interactively, enabling the user to call dir() on a Roku instance and see the commands and sensors as well as the defined methods.

Previously:

>>> r = roku.Roku.discover()[0]
>>> dir(r)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', 
'__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', 
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 
'_app_for_id', '_app_for_name', '_call', '_conn', '_connect', '_get', '_post', 'active_app', 'apps', 'commands', 'current_app', 
'device_info', 'discover', 'host', 'icon', 'input', 'launch', 'port', 'power_state', 'store', 'timeout', 'touch', 'tv_channels']

With PR:

>>> r = roku.Roku.discover()[0]
>>> dir(r)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', 
'__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', 
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 
'_app_for_id', '_app_for_name', '_call', '_conn', '_connect', '_get', '_post', 'acceleration', 'active_app', 'apps', 'back', 'backspace', 
'channel_down', 'channel_up', 'commands', 'current_app', 'device_info', 'discover', 'down', 'enter', 'find_remote', 'forward', 'home', 
'host', 'icon', 'info', 'input', 'input_av1', 'input_hdmi1', 'input_hdmi2', 'input_hdmi3', 'input_hdmi4', 'input_tuner', 'launch', 'left', 
'literal', 'magnetic', 'orientation', 'play', 'port', 'power', 'power_state', 'poweroff', 'poweron', 'replay', 'reverse', 'right', 'rotation', 
'search', 'select', 'store', 'timeout', 'touch', 'tv_channels', 'up', 'volume_down', 'volume_mute', 'volume_up']
jcarbaugh commented 1 year ago

Very smart, thank you!