-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support older players with incomplete data (#102)
* Support older versions * Test get system info with unsupported * Add load players test
- Loading branch information
1 parent
e3f2772
commit 1a2fa30
Showing
17 changed files
with
698 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Define the common module.""" | ||
|
||
from typing import cast | ||
|
||
from pyheos.const import TARGET_VERSION | ||
|
||
|
||
def is_supported_version( | ||
version: str | None, min_version: str = TARGET_VERSION | ||
) -> bool: | ||
"""Check if a version is supported. | ||
Args: | ||
version (str): The version to check. | ||
min_version (str): The minimum version. | ||
Returns: | ||
bool: True if the version is supported, False otherwise. | ||
""" | ||
if version is None: | ||
return False | ||
try: | ||
sem_ver = get_sem_ver(version) | ||
except ValueError: | ||
return False | ||
min_sem_ver = get_sem_ver(min_version) | ||
for i, ver in enumerate(sem_ver): | ||
if ver < min_sem_ver[i]: | ||
return False | ||
if ver > min_sem_ver[i]: | ||
return True | ||
return True | ||
|
||
|
||
def get_sem_ver(version: str) -> tuple[int, int, int]: | ||
"""Get the semantic version from a string. | ||
Args: | ||
version (str): The version string. | ||
Returns: | ||
tuple: The semantic version as a tuple. | ||
""" | ||
return cast(tuple[int, int, int], tuple(map(int, version.split(".", 3)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"heos": { | ||
"command": "player/get_players", | ||
"result": "success", | ||
"message": "" | ||
}, | ||
"payload": [{ | ||
"name": "Back Patio", | ||
"pid": 1, | ||
"model": "HEOS Link" | ||
}, { | ||
"name": "Front Porch", | ||
"pid": 2, | ||
"model": "HEOS 5", | ||
"version": "1.583.147", | ||
"ip": "127.0.0.2", | ||
"network": "wifi", | ||
"lineout": 0 | ||
} | ||
] | ||
} |
Oops, something went wrong.