Skip to content

Commit

Permalink
PR Suggestions (#1)
Browse files Browse the repository at this point in the history
* Reorder _cmd function

* Code suggestion change

* Code suggestion change

* Re-Ordering
  • Loading branch information
StephenGoodall committed Feb 18, 2022
1 parent 37746de commit a110664
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
28 changes: 14 additions & 14 deletions androidtv/basetv/basetv.py
Expand Up @@ -116,6 +116,20 @@ def customize_command(self, custom_command, value):
elif custom_command in self._custom_commands:
del self._custom_commands[custom_command]

def _cmd_audio_state(self):
"""Get the command used to retrieve the current audio state for this device.
Returns
-------
str
The device-specific ADB shell command used to determine the current audio state
"""
if constants.CUSTOM_AUDIO_STATE in self._custom_commands:
return self._custom_commands[constants.CUSTOM_AUDIO_STATE]

return constants.CMD_AUDIO_STATE

def _cmd_current_app(self):
"""Get the command used to retrieve the current app for this device.
Expand Down Expand Up @@ -238,20 +252,6 @@ def _cmd_turn_on(self):

return constants.CMD_TURN_ON_ANDROIDTV

def _cmd_audio_state(self):
"""Get the command used to retrieve the current audio state for this device.
Returns
-------
str
The device-specific ADB shell command used to determine the current audio state
"""
if constants.CUSTOM_AUDIO_STATE in self._custom_commands:
return self._custom_commands[constants.CUSTOM_AUDIO_STATE]

return constants.CMD_AUDIO_STATE

# ======================================================================= #
# #
# ADB methods #
Expand Down
2 changes: 1 addition & 1 deletion androidtv/basetv/basetv_async.py
Expand Up @@ -242,7 +242,7 @@ async def audio_state(self):
Returns
-------
str, None
The audio state, as determined from the ADB shell command :py:const:`androidtv.constants.CMD_AUDIO_STATE`, or ``None`` if it could not be determined
The audio state, or ``None`` if it could not be determined
"""
audio_state_response = await self._adb.shell(self._cmd_audio_state())
Expand Down
2 changes: 1 addition & 1 deletion androidtv/basetv/basetv_sync.py
Expand Up @@ -242,7 +242,7 @@ def audio_state(self):
Returns
-------
str, None
The audio state, as determined from the ADB shell command :py:const:`androidtv.constants.CMD_AUDIO_STATE`, or ``None`` if it could not be determined
The audio state, or ``None`` if it could not be determined
"""
audio_state_response = self._adb.shell(self._cmd_audio_state())
Expand Down
6 changes: 3 additions & 3 deletions androidtv/constants.py
Expand Up @@ -35,31 +35,31 @@ class DeviceEnum(IntEnum):
INTENT_HOME = "android.intent.category.HOME"

# Customizable commands
CUSTOM_AUDIO_STATE = "audio_state"
CUSTOM_CURRENT_APP = "current_app"
CUSTOM_CURRENT_APP_MEDIA_SESSION_STATE = "current_app_media_session_state"
CUSTOM_LAUNCH_APP = "launch_app"
CUSTOM_RUNNING_APPS = "running_apps"
CUSTOM_TURN_OFF = "turn_off"
CUSTOM_TURN_ON = "turn_on"
CUSTOM_AUDIO_STATE = "audio_state"
CUSTOMIZABLE_COMMANDS = {
CUSTOM_AUDIO_STATE,
CUSTOM_CURRENT_APP,
CUSTOM_CURRENT_APP_MEDIA_SESSION_STATE,
CUSTOM_LAUNCH_APP,
CUSTOM_RUNNING_APPS,
CUSTOM_TURN_OFF,
CUSTOM_TURN_ON,
CUSTOM_AUDIO_STATE,
}

#: The subset of `CUSTOMIZABLE_COMMANDS` that is potentially used in the ``update()`` method
HA_CUSTOMIZABLE_COMMANDS = (
CUSTOM_AUDIO_STATE,
CUSTOM_CURRENT_APP_MEDIA_SESSION_STATE,
CUSTOM_LAUNCH_APP,
CUSTOM_RUNNING_APPS,
CUSTOM_TURN_OFF,
CUSTOM_TURN_ON,
CUSTOM_AUDIO_STATE,
)

# echo '1' if the previous shell command was successful
Expand Down

0 comments on commit a110664

Please sign in to comment.