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:
24
jc/utils.py
24
jc/utils.py
@ -97,6 +97,20 @@ def error_message(message_lines: List[str]) -> None:
|
|||||||
_safe_print(message, file=sys.stderr)
|
_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:
|
def compatibility(mod_name: str, compatible: List, quiet: bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
Checks for the parser's compatibility with the running OS
|
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
|
None - just prints output to STDERR
|
||||||
"""
|
"""
|
||||||
if not quiet:
|
if not quiet and not is_compatible(compatible):
|
||||||
platform_found = False
|
|
||||||
|
|
||||||
for platform in compatible:
|
|
||||||
if sys.platform.startswith(platform):
|
|
||||||
platform_found = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if not platform_found:
|
|
||||||
mod = mod_name.split('.')[-1]
|
mod = mod_name.split('.')[-1]
|
||||||
compat_list = ', '.join(compatible)
|
compat_list = ', '.join(compatible)
|
||||||
warning_message([
|
warning_message([
|
||||||
|
Reference in New Issue
Block a user