1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

refactor - create is_compatible function

This commit is contained in:
Kelly Brazil
2022-05-23 13:52:08 -07:00
parent c21c334b73
commit 9f4ba80000

View File

@ -97,6 +97,20 @@ def error_message(message_lines: List[str]) -> None:
_safe_print(message, file=sys.stderr)
def is_compatible(compatible: List) -> bool:
"""
Returns True if the parser is compatible with the running OS platform.
"""
platform_found = False
for platform in compatible:
if sys.platform.startswith(platform):
platform_found = True
break
return platform_found
def compatibility(mod_name: str, compatible: List, quiet: bool = False) -> None:
"""
Checks for the parser's compatibility with the running OS
@ -116,15 +130,7 @@ def compatibility(mod_name: str, compatible: List, quiet: bool = False) -> None:
None - just prints output to STDERR
"""
if not quiet:
platform_found = False
for platform in compatible:
if sys.platform.startswith(platform):
platform_found = True
break
if not platform_found:
if not quiet and not is_compatible(compatible):
mod = mod_name.split('.')[-1]
compat_list = ', '.join(compatible)
warning_message([