From c147a2ffc6c2e404ac7586971aa8a805933fdc3b Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Tue, 7 Apr 2026 07:42:18 +0000 Subject: [PATCH] [-] export distros --- tools/deploy-release.py | 2 +- tools/list_distros.py | 96 +---------------------------------------- 2 files changed, 3 insertions(+), 95 deletions(-) diff --git a/tools/deploy-release.py b/tools/deploy-release.py index db0525e9..56692d5d 100755 --- a/tools/deploy-release.py +++ b/tools/deploy-release.py @@ -170,8 +170,8 @@ if __name__ == '__main__': args = parser.parse_args() pre_check() - # export_distros() # Removed: not needed anymore for python distro generation edit_versions(args.version) + finalize_neofetch() post_check() create_release(args.version) diff --git a/tools/list_distros.py b/tools/list_distros.py index 068c8afa..4a670787 100755 --- a/tools/list_distros.py +++ b/tools/list_distros.py @@ -97,98 +97,6 @@ def generate_help(max_len: int, leading: str): return wrap(out, max_len, leading) -def match_condition(match: str) -> str: - """ - Convert simple glob match condition to python - """ - match = [s.strip() for s in match.split("|")] - conds = [] - for m in match: - stripped = m.strip("*'\"").lower() - if '*' in stripped or '"' in stripped: - print(f"TODO: Cannot properly parse: {m}") - - # Exact matches - if m.strip("*") == m: - conds.append(f"name == '{stripped}'") - continue - - # Both sides are * - if m.startswith("*") and m.endswith("*"): - conds.append(f"(name.startswith('{stripped}') or name.endswith('{stripped}'))") - continue - - # Ends with * - if m.endswith("*"): - conds.append(f"name.startswith('{stripped}')") - continue - - # Starts with * - if m.startswith("*"): - conds.append(f"name.endswith('{stripped}')") - continue - - return ' or '.join(conds) - - -def export_distro(d: AsciiArt) -> str: - """ - Export distro to a python script - """ - # Escape variable name - varname = d.name.lower() - for s in string.punctuation + ' ': - varname = varname.replace(s, '_') - - # Remove accents - varname = unicodedata.normalize('NFKD', varname).encode('ascii', 'ignore').decode('utf-8') - - # Escape/unescape ascii - ascii = d.ascii.replace("\\\\", "\\") - - quotes = '"""' - if '"""' in ascii: - quotes = "'''" - if "'''" in ascii: - print(f"TODO: Cannot escape ascii because both \"\"\" and ''' exist: {ascii}") - - script = f"""# This file is automatically generated. Please do not modify. - -from . import AsciiArt - -{varname} = AsciiArt(match=r'''{d.match}''', color='{d.color}', ascii=r{quotes} -{ascii} -{quotes}) - """ - write(Path(__file__).parent.parent / f'hyfetch/distros/{varname}.py', script) - - # Generate python script for identifying the distro - return f""" - if {match_condition(d.match)}: - from .{varname} import {varname} - return {varname} - """ - - -def export_distros(): - distros = parse_ascii_distros() - # print('\n'.join(d.match for d in distros)) - py = """# This file is automatically generated. Please do not modify. - -from __future__ import annotations - -from . import AsciiArt - -def detect(name: str) -> AsciiArt | None: - if not name: - return None - name = name.lower() -""" - py += '\n'.join(export_distro(d).strip('\n') for d in distros) - write(Path(__file__).parent.parent / f'hyfetch/distros/distro_detector.py', py) - - if __name__ == '__main__': - # print(generate_help(100, ' ' * 32)) - # print(generate_help(100, '# ')) - export_distros() + print(generate_help(100, '# ')) +