fix(format): formatted the python project

This commit is contained in:
Artur Manuel 2024-08-05 10:54:27 +01:00
commit 648f22d3c7
Failed to generate hash of commit
2 changed files with 41 additions and 24 deletions

View file

@ -1,5 +1,6 @@
from whyfetch.data import Data
def separator_from_longest_prop(props: list[str]):
j: int = 0
@ -10,7 +11,8 @@ def separator_from_longest_prop(props: list[str]):
else:
continue
return ""*j
return "" * j
class Colours:
red: str = "\x1b[1;31m"
@ -18,6 +20,7 @@ class Colours:
white: str = "\x1b[1;39m"
magenta: str = "\x1b[1;35m"
def __main__():
d: Data = Data()
@ -28,17 +31,29 @@ def __main__():
f"shell: {d.shell}",
f"ram: {d.ram}",
f"up: {d.uptime}",
f"locale: {d.locale}"
f"locale: {d.locale}",
]
separator: str = separator_from_longest_prop(props)
print(f'{Colours.white}━━━━━━━━━━━━━━━{separator}')
print(f' {Colours.red}_.----._{Colours.white} {Colours.magenta}{d.username}{Colours.white}@{Colours.magenta}{d.hostname}')
print(f' {Colours.red}.\' \'.{Colours.white} {Colours.magenta}kernel:{Colours.white} {d.kernel}')
print(f'{Colours.red}/{Colours.white}._ _.--._ {Colours.red}\\{Colours.white} {Colours.magenta}os:{Colours.white} {d.os}')
print(f'|_ \'-\' _.._ `| {Colours.magenta}shell:{Colours.white} {d.shell}')
print(f'{Colours.blue}\\{Colours.white} `---\' `-{Colours.blue}/{Colours.white} {Colours.magenta}ram:{Colours.white} {d.ram}')
print(f' {Colours.blue}\'._ _.\'{Colours.white} {Colours.magenta}up:{Colours.white} {d.uptime}')
print(f' {Colours.blue}\'----\'{Colours.white} {Colours.magenta}locale:{Colours.white} {d.locale}')
print(f'━━━━━━━━━━━━━━━{separator}')
print(f"{Colours.white}━━━━━━━━━━━━━━━{separator}")
print(
f" {Colours.red}_.----._{Colours.white} {Colours.magenta}{d.username}{Colours.white}@{Colours.magenta}{d.hostname}"
)
print(
f" {Colours.red}.' '.{Colours.white} {Colours.magenta}kernel:{Colours.white} {d.kernel}"
)
print(
f"{Colours.red}/{Colours.white}._ _.--._ {Colours.red}\\{Colours.white} {Colours.magenta}os:{Colours.white} {d.os}"
)
print(f"|_ '-' _.._ `| {Colours.magenta}shell:{Colours.white} {d.shell}")
print(
f"{Colours.blue}\\{Colours.white} `---' `-{Colours.blue}/{Colours.white} {Colours.magenta}ram:{Colours.white} {d.ram}"
)
print(
f" {Colours.blue}'._ _.'{Colours.white} {Colours.magenta}up:{Colours.white} {d.uptime}"
)
print(
f" {Colours.blue}'----'{Colours.white} {Colours.magenta}locale:{Colours.white} {d.locale}"
)
print(f"━━━━━━━━━━━━━━━{separator}")

View file

@ -12,6 +12,7 @@ import os
ures: pl.uname_result = pl.uname()
sys: str = pl.system()
class Data:
def __init__(self) -> None:
self.username: str = gp.getuser()
@ -27,9 +28,9 @@ class Data:
def get_os(self) -> str:
if "Linux" == ures.system:
linux_res: dict[str, str] = pl.freedesktop_os_release()
return linux_res['PRETTY_NAME']
return linux_res["PRETTY_NAME"]
if [ "FreeBSD", "OpenBSD", "NetBSD" ] not in [ ures.system ]:
if ["FreeBSD", "OpenBSD", "NetBSD"] not in [ures.system]:
return ures.system
if sys == "Darwin":
@ -57,7 +58,7 @@ class Data:
return shell
def get_ram(self) -> str:
to_gb: Callable[[int], float] = lambda s: s / (1024 ** 3)
to_gb: Callable[[int], float] = lambda s: s / (1024**3)
vm: NamedTuple = ps.virtual_memory()
total: float = to_gb(vm.total)
used: float = to_gb(vm.used)
@ -68,9 +69,10 @@ class Data:
current_uptime: tm.struct_time = tm.gmtime(tm.time() - ps.boot_time())
return tm.strftime("%H hours, %M minutes, %S seconds", current_uptime)
def provide_default_shell() -> str:
if os.name == 'nt':
return os.environ['COMSPEC']
elif os.name == 'posix':
return os.environ['SHELL']
raise NotImplementedError(f'OS {os.name!r} support not available')
if os.name == "nt":
return os.environ["COMSPEC"]
elif os.name == "posix":
return os.environ["SHELL"]
raise NotImplementedError(f"OS {os.name!r} support not available")