[M] Move distro.py to distros/__init__.py

This commit is contained in:
Hykilpikonna 2022-12-11 07:40:53 -05:00
parent 0c4b239266
commit bc2a8dbf3c
No known key found for this signature in database
GPG key ID: 256CD01A41D7FA26
329 changed files with 340 additions and 338 deletions

View file

@ -5,7 +5,6 @@ List distributions supported by neofetch
"""
from __future__ import annotations
import re
import string
import textwrap
from pathlib import Path
@ -13,7 +12,7 @@ from pathlib import Path
import regex
from hypy_utils import write
from hyfetch.distro import AsciiArt
from hyfetch.distros import AsciiArt
RE_SPLIT = regex.compile('EOF[ \n]*?;;')
RE_COLORS = regex.compile("""(?<=set_colors )[a-z\\d ]+(?=\n)""")
@ -144,7 +143,7 @@ def export_distro(d: AsciiArt) -> str:
ascii = d.ascii.replace('"""', '\\"""').replace("\\\\", "\\")
script = f"""
from ..distro import AsciiArt
from . import AsciiArt
{varname} = AsciiArt(match=r'''{d.match}''', color='{d.color}', ascii=r\"""
{ascii}
@ -165,9 +164,13 @@ def export_distros():
# print('\n'.join(d.match for d in distros))
py = """
# This file is automatically generated. Please do not modify.\n
from ..distro import AsciiArt
from __future__ import annotations
def detect(name: str) -> AsciiArt:
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)