1
0
mirror of https://github.com/HorlogeSkynet/archey4 synced 2025-06-14 16:00:10 +02:00

[LOGOS] Implements support for alternative styles and adds Apple "retro"

> Closes #98.
This commit is contained in:
Samuel FORESTIER
2021-04-26 14:42:38 +02:00
parent 085ce1af67
commit 301964238f
5 changed files with 52 additions and 1 deletions

@ -12,6 +12,7 @@ and this project (partially) adheres to [Semantic Versioning](https://semver.org
- Homebrew formula in the default tap
- `CLICOLOR[_FORCE]` environment variables support
- `LOGNAME` environment variable support for `User`
- Alternative logo style support (see `-l` option with `retro` parameter for Darwin)
### Changed
- Prevent text truncation when writing output to a pipe

@ -41,6 +41,10 @@ supported distribution identifier to show the logo of, pass `unknown` to list th
output entries data to JSON format, use multiple times to increase
indentation
.IP "-l, --logo-style IDENTIFIER"
alternative logo style identifier to show instead of the distribution default one.
For instance, you can try 'retro' to prefer old Apple's logo on Darwin platforms
.IP "-s, --screenshot [FILENAME]"
take a screenshot once execution is done, optionally specify a target
path

@ -92,6 +92,12 @@ def args_parsing() -> argparse.Namespace:
action='count',
help='output entries data to JSON format, use multiple times to increase indentation'
)
parser.add_argument(
'-l', '--logo-style',
metavar='IDENTIFIER',
help="alternative logo style identifier to show instead of the distribution default one. "
"For instance, you can try 'retro' to prefer old Apple's logo on Darwin platforms"
)
parser.add_argument(
'-s', '--screenshot',
metavar='PATH',
@ -126,6 +132,7 @@ def main():
available_entries = [{'type': entry_name} for entry_name in Entries.__members__.keys()]
output = Output(
preferred_logo_style=args.logo_style,
preferred_distribution=args.distribution,
format_to_json=args.json
)

@ -24,3 +24,35 @@ LOGO = [
"""{c[0]} ;KMMMMMMMWXXWMMMMMMMk. """,
"""{c[0]} .cooc,. .,coo:. """
]
# Alternative logo : Apple's "retro" logo.
COLORS_RETRO = [
Colors.CYAN_BRIGHT,
Colors.GREEN_BRIGHT,
Colors.YELLOW_BRIGHT,
Colors.YELLOW_NORMAL,
Colors.RED_BRIGHT,
Colors.MAGENTA_BRIGHT,
Colors.BLUE_BRIGHT
]
LOGO_RETRO = [
"""{c[0]} {c[1]}'c.{c[0]} """,
"""{c[0]} {c[1]},xNMM.{c[0]} """,
"""{c[0]} {c[1]}.OMMMMo{c[0]} """,
"""{c[0]} {c[1]}OMMM0,{c[0]} """,
"""{c[0]} {c[1]}.;loddo:'{c[0]} {c[1]}loolloddol;.{c[0]} """,
"""{c[0]} {c[1]}cKMMMMMMMMMMNWMMMMMMMMMM0:{c[0]} """,
"""{c[0]} {c[2]}.KMMMMMMMMMMMMMMMMMMMMMMMWd.{c[0]} """,
"""{c[0]} {c[2]}XMMMMMMMMMMMMMMMMMMMMMMMX.{c[0]} """,
"""{c[0]} {c[3]}MMMMMMMMMMMMMMMMMMMMMMMM:{c[0]} """,
"""{c[0]} {c[3]}MMMMMMMMMMMMMMMMMMMMMMMM:{c[0]} """,
"""{c[0]} {c[4]}MMMMMMMMMMMMMMMMMMMMMMMMX.{c[0]} """,
"""{c[0]} {c[4]}kMMMMMMMMMMMMMMMMMMMMMMMMWd.{c[0]} """,
"""{c[0]} {c[5]}.XMMMMMMMMMMMMMMMMMMMMMMMMMMk{c[0]} """,
"""{c[0]} {c[5]}.XMMMMMMMMMMMMMMMMMMMMMMMMK.{c[0]} """,
"""{c[0]} {c[6]}kMMMMMMMMMMMMMMMMMMMMMMd{c[0]} """,
"""{c[0]} {c[6]};KMMMMMMMWXXWMMMMMMMk.{c[0]} """,
"""{c[0]} {c[6]}.cooc,.{c[0]} {c[6]}.,coo:.{c[0]} """
]

@ -27,6 +27,7 @@ class Output:
def __init__(self, **kwargs):
# Fetches passed arguments.
self._format_to_json = kwargs.get('format_to_json')
preferred_logo_style = (kwargs.get('preferred_logo_style') or '').upper()
try:
# If set, force the distribution to `preferred_distribution` argument.
@ -37,7 +38,13 @@ class Output:
# Retrieve distribution's logo module before copying and DRY-ing its attributes.
logo_module = lazy_load_logo_module(self._distribution.value)
self._logo, self._colors = logo_module.LOGO.copy(), logo_module.COLORS.copy()
# If set and available, fetch an alternative logo style from module.
if preferred_logo_style and hasattr(logo_module, f"LOGO_{preferred_logo_style}"):
self._logo = getattr(logo_module, f"LOGO_{preferred_logo_style}").copy()
self._colors = getattr(logo_module, f"COLORS_{preferred_logo_style}").copy()
else:
self._logo, self._colors = logo_module.LOGO.copy(), logo_module.COLORS.copy()
# If `os-release`'s `ANSI_COLOR` option is set, honor it.
ansi_color = Distributions.get_ansi_color()