From 769580314c159e80cad9c123462429b7cd7059db Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Mon, 1 Aug 2022 18:38:38 -0400 Subject: [PATCH] [+] Create help ascii list generator --- tools/list_distros.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/list_distros.py b/tools/list_distros.py index db9647a3..e0b87917 100644 --- a/tools/list_distros.py +++ b/tools/list_distros.py @@ -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())