[+] Create help ascii list generator

This commit is contained in:
Azalea (on HyDEV-Daisy) 2022-08-01 18:38:38 -04:00
parent 8d9d8a487e
commit 769580314c

View file

@ -83,3 +83,27 @@ def parse_ascii_distros() -> list[AsciiArt]:
out = [parse_block(block) for block in blocks]
return [v for v in out if v]
def wrap(text: str, max_len: int, leading_space: int):
length = max_len - leading_space
lines = [line for raw in text.split('\n') for line in textwrap.wrap(raw, length) or ['']]
return '\n'.join(' ' * leading_space + line if line else line for line in lines)
def generate_help(max_len: int = 100, leading_space: int = 32):
distros = sorted(list({a.get_friendly_name() for a in parse_ascii_distros()}), key=str.casefold)
smalls = [d.replace('_small', '') for d in distros if d.endswith('_small')]
olds = [d.replace('_old', '') for d in distros if d.endswith('_old')]
distros = [d for d in distros if not d.endswith('_small') and not d.endswith('_old')]
out = f"NOTE: {', '.join(distros)} have ascii logos.\n\n"\
f"NOTE: {', '.join(olds)} have 'old' logo variants, use {{distro}}_old to use them.\n\n" \
f"NOTE: {', '.join(smalls)} have 'small' logo variants, use {{distro}}_small to use them."
return wrap(out, max_len, leading_space)
if __name__ == '__main__':
print(generate_help(100, 0))
print(generate_help())