mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-09 13:52:00 -04:00

New "package" flow, arguments now provided during utility call (README) New "main" flow, using old "run_utility" method of BIOSUtility (README) Removed "run_utility" and "show_version" methods from base BIOSUtility Removed argparse argument parsing logic from base BIOSUtility class Removed notion of "pause" (i.e. user action) from BIOSUtility logic Adjusted the README with usage info for "main" and "package" flows
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
#!/usr/bin/env python3 -B
|
|
# coding=utf-8
|
|
|
|
"""
|
|
Copyright (C) 2022-2024 Plato Mavropoulos
|
|
"""
|
|
|
|
import sys
|
|
import platform
|
|
|
|
from biosutilities.common.texts import to_string
|
|
|
|
|
|
def system_platform() -> tuple[str, bool, bool]:
|
|
""" Get OS platform """
|
|
|
|
sys_os: str = platform.system()
|
|
|
|
is_win: bool = sys_os == 'Windows'
|
|
|
|
is_lnx: bool = sys_os in ('Linux', 'Darwin')
|
|
|
|
return sys_os, is_win, is_lnx
|
|
|
|
|
|
def python_version() -> tuple:
|
|
""" Get Python version """
|
|
|
|
return sys.version_info
|
|
|
|
|
|
def printer(message: str | list | tuple | None = None, padding: int = 0, new_line: bool = True,
|
|
sep_char: str = ' ', strip: bool = False) -> None:
|
|
""" Show message(s), controlling padding, newline, stripping, pausing & separating """
|
|
|
|
message_string: str = to_string(in_object='' if message is None else message, sep_char=sep_char)
|
|
|
|
message_output: str = '\n' if new_line else ''
|
|
|
|
for message_line_index, message_line_text in enumerate(message_string.split('\n')):
|
|
line_new: str = '' if message_line_index == 0 else '\n'
|
|
|
|
line_text: str = message_line_text.strip() if strip else message_line_text
|
|
|
|
message_output += f'{line_new}{" " * padding}{line_text}'
|
|
|
|
print(message_output)
|