[F] Fix tripple-quote escaping #222

This commit is contained in:
Azalea 2023-12-22 01:58:15 -05:00
parent 807eed022d
commit caa1547e8c
13 changed files with 63 additions and 36 deletions

View file

@ -2,7 +2,7 @@
from . import AsciiArt from . import AsciiArt
aosc_os = AsciiArt(match=r'''"AOSC OS"*''', color='4 0 1 3', ascii=r""" aosc_os = AsciiArt(match=r'''"AOSC OS"*''', color='4 0 1 3', ascii=r'''
${c2} __ ${c2} __
${c2}gpBBBBBBBBBP ${c2}gpBBBBBBBBBP
${c2}_gBBBBBBBBBRP ${c2}_gBBBBBBBBBRP
@ -13,12 +13,12 @@ ${c2} __
${c4}_w@@@@@@@@@@@@@@@@P" ${c1}_g@@@@@@@P" ${c4}_w@@@@@@@@@@@@@@@@P" ${c1}_g@@@@@@@P"
${c4}_g@@@@@@@@@@@@@@@N"` ${c1}VMNN@NNNM^` ${c4}_g@@@@@@@@@@@@@@@N"` ${c1}VMNN@NNNM^`
${c4}^MMM@@@@@@@@@@@MP" ${c3},ggppww__ ${c4}^MMM@@@@@@@@@@@MP" ${c3},ggppww__
${c4}`"\"\"\"" ${c3}_wNNNNNNNNNNNNNNNNNNN ${c4}`""""" ${c3}_wNNNNNNNNNNNNNNNNNNN
${c3}_gBNNNNNNNNNNNNNNNNNP" ${c3}_gBNNNNNNNNNNNNNNNNNP"
${c3}_wNNNNNNNNNNNNNNNNNNMP` ${c3}_wNNNNNNNNNNNNNNNNNNMP`
${c3}_gBNNNNNNNNNNNNNNNNNP" ${c3}_gBNNNNNNNNNNNNNNNNNP"
${c3}_wNNNNNNNNNNNNNNNNNNNM^ ${c3}_wNNNNNNNNNNNNNNNNNNNM^
${c3}""Y^^MNNNNNNNNNNNNP` ${c3}""Y^^MNNNNNNNNNNNNP`
${c3}`"\"\""\"\"" ${c3}`"""""""
""") ''')

View file

@ -2,10 +2,10 @@
from . import AsciiArt from . import AsciiArt
debian = AsciiArt(match=r'''"Debian"*''', color='1 7 3', ascii=r""" debian = AsciiArt(match=r'''"Debian"*''', color='1 7 3', ascii=r'''
${c2} _,met$$$$$gg. ${c2} _,met$$$$$gg.
,g$$$$$$$$$$$$$$$P. ,g$$$$$$$$$$$$$$$P.
,g$$P" "\""Y$$.". ,g$$P" """Y$$.".
,$$P' `$$$. ,$$P' `$$$.
',$$P ,ggs. `$$b: ',$$P ,ggs. `$$b:
`d$$' ,$P"' ${c1}.${c2} $$$ `d$$' ,$P"' ${c1}.${c2} $$$
@ -19,6 +19,6 @@ ${c2} `Y$$
`$$b. `$$b.
`Y$$b. `Y$$b.
`"Y$b._ `"Y$b._
`"\"" `"""
""") ''')

View file

@ -624,6 +624,10 @@ def detect(name: str) -> AsciiArt | None:
from .interix import interix from .interix import interix
return interix return interix
if name.startswith('ironclad'):
from .ironclad import ironclad
return ironclad
if name.startswith('januslinux') or name.startswith('janus') or name.startswith('ataraxia linux') or name.startswith('ataraxia'): if name.startswith('januslinux') or name.startswith('janus') or name.startswith('ataraxia linux') or name.startswith('ataraxia'):
from .januslinux import januslinux from .januslinux import januslinux
return januslinux return januslinux

View file

@ -2,7 +2,7 @@
from . import AsciiArt from . import AsciiArt
haiku = AsciiArt(match=r'''"Haiku"*''', color='1 3 7 2', ascii=r""" haiku = AsciiArt(match=r'''"Haiku"*''', color='1 3 7 2', ascii=r'''
${c3} ${c3}
MMMM MMMM MMMM MMMM
@ -16,6 +16,6 @@ ${c3} MMMM${c4} .cOMMMMM|/MMMMM/`
MM${c4}MMMMMMM/`:MMM/ ${c3}MMMM MM${c4}MMMMMMM/`:MMM/ ${c3}MMMM
MMMM MMMM MMMM MMMM
MMMM MMMM MMMM MMMM
"\"\"" "\"\"" """" """"
""") ''')

View file

@ -0,0 +1,19 @@
# This file is automatically generated. Please do not modify.
from . import AsciiArt
ironclad = AsciiArt(match=r'''"Ironclad"*''', color='5 7 0', ascii=r"""
${c3}
&#BGPPPPPG#&
B5?77!!?YJJ7!7YBB&
&G5YJ77!7JYYYYYBPJ&PY#
#PYYYYYY?!?YYYYY7?7JP5JJ
B?YYYYYY7!!7JYYYYJ!!?JJJ5
&& B7?J?77?7!!!!!77777!7Y5YYBBPGGG&
G77?YBB!!!!!!!!!!!!!JYJ??7JYJJY# PYPPG&
J777JB?!7JJ???!!!7?JYYYYYPJ!7JB
GYYG #JJJJJ??7!!!JYYY5PGB&GB&
#Y!?GB5YYJY5PG###&
GJJP
""")

View file

@ -7,7 +7,7 @@ ${c2} /==\
\==/ \==/
${c1} · · · · · · · ${c1} · · · · · · ·
· · · · · · · · · · · · · · · · · · · ·
· · · ${c2}.-======-.${c1}· · · · · · · ${c2}.-======-.${c1}· · · ·
${c2} .::.${c1} ·${c2}.-============-.${c1}· ${c2}.::. ${c2} .::.${c1} ·${c2}.-============-.${c1}· ${c2}.::.
.:==:${c1}· ${c2}.:===:'${c1}. ·· .${c2}':===:.${c1} ·${c2}:==:. .:==:${c1}· ${c2}.:===:'${c1}. ·· .${c2}':===:.${c1} ·${c2}:==:.
.:===:${c1} · ${c2}:===.${c1} · ${c3}.--.${c1} · ${c2}.===:${c1} · ${c2}:===:. .:===:${c1} · ${c2}:===.${c1} · ${c3}.--.${c1} · ${c2}.===:${c1} · ${c2}:===:.

View file

@ -2,13 +2,13 @@
from . import AsciiArt from . import AsciiArt
puffos = AsciiArt(match=r'''"PuffOS"*''', color='3', ascii=r""" puffos = AsciiArt(match=r'''"PuffOS"*''', color='3', ascii=r'''
${c1} ${c1}
_,..._,m, _,..._,m,
,/' '""; ,/' '"";
/ ". / ".
,'mmmMMMMmm. \ ,'mmmMMMMmm. \
_/-"^^^^^"\""%#%mm, ; _/-"^^^^^"""%#%mm, ;
,m,_,' "###) ;, ,m,_,' "###) ;,
(###% \#/ ;##mm. (###% \#/ ;##mm.
^#/ __ ___ ; (######) ^#/ __ ___ ; (######)
@ -16,5 +16,5 @@ ${c1}
_; (#\"// \"/#) ; ,/ _; (#\"// \"/#) ; ,/
@##\ \##/ = `"=" ,;mm/ @##\ \##/ = `"=" ,;mm/
`\##>.____,...,____,<####@ `\##>.____,...,____,<####@
""") ''')

View file

@ -2,7 +2,7 @@
from . import AsciiArt from . import AsciiArt
salix = AsciiArt(match=r'''"Salix"*''', color='2', ascii=r""" salix = AsciiArt(match=r'''"Salix"*''', color='2', ascii=r'''
${c1} __s_aaaaaaaaauuoXSSSSSSSS: ${c1} __s_aaaaaaaaauuoXSSSSSSSS:
._xSSSSSSSSSSSSSSSSSSSSSSSSSS: ._xSSSSSSSSSSSSSSSSSSSSSSSSSS:
_aSSSSSSSSSSSSSSSSSSSSSSSSSSSSS: _aSSSSSSSSSSSSSSSSSSSSSSSSSSSSS:
@ -15,13 +15,13 @@ ${c1} __s_aaaaaaaaauuoXSSSSSSSS:
oSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS; oSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS;
:XSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS; :XSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS;
{SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS {SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
-"\"\""\"\""\"\""\"\""\"\""\"\""\"\""\"\""\"\""\"\""\"\"\""' -"""""""""""""""""""""""""""""""""""'
<assssssssssssssssssssssssssssssss> <assssssssssssssssssssssssssssssss>
nSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS} nSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS}
nSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS}` nSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS}`
XSSSSSSSSSSSSSSSSSSSSSSSSSSSS"` XSSSSSSSSSSSSSSSSSSSSSSSSSSSS"`
SSSSSSSSSSSSSSSSSSSSSSSSS!"` SSSSSSSSSSSSSSSSSSSSSSSSS!"`
-"\"\""\"\""\"\""\"\""\"\""\"\""\"\""` -""""""""""""""""""""""`
""") ''')

View file

@ -2,7 +2,7 @@
from . import AsciiArt from . import AsciiArt
skiffos = AsciiArt(match=r'''"SkiffOS"*''', color='4 7', ascii=r""" skiffos = AsciiArt(match=r'''"SkiffOS"*''', color='4 7', ascii=r'''
${c2} ${c2}
,@@@@@@@@@@@w,_ ,@@@@@@@@@@@w,_
${c2}====~~~,,.${c2}A@@@@@@@@@@@@@@@@@W,_ ${c2}====~~~,,.${c2}A@@@@@@@@@@@@@@@@@W,_
@ -12,6 +12,6 @@ ${c2}
${c2}*@@@@@@@@@@@@@@@@@@@@@@@@@p${c1}||||==, ${c2}*@@@@@@@@@@@@@@@@@@@@@@@@@p${c1}||||==,
${c1}`'||LLL{{""${c2}@$B@@@@@@@@@@@@@@@p${c1}|| ${c1}`'||LLL{{""${c2}@$B@@@@@@@@@@@@@@@p${c1}||
${c1}`~=|||||||||||L"${c2}$@@@@@@@@@@@ ${c1}`~=|||||||||||L"${c2}$@@@@@@@@@@@
${c1}````'"\"\""\"\""${c2}'"\"\""\"\"\"" ${c1}````'"""""""${c2}'""""""""
""") ''')

View file

@ -2,14 +2,14 @@
from . import AsciiArt from . import AsciiArt
slackel = AsciiArt(match=r'''"Slackel"*''', color='3', ascii=r""" slackel = AsciiArt(match=r'''"Slackel"*''', color='3', ascii=r'''
${c1} _aawmmmmmwwaaaaas,,,_. ${c1} _aawmmmmmwwaaaaas,,,_.
.ammmmm###mmmmmmm###BQmm##mws .ammmmm###mmmmmmm###BQmm##mws
.am###mmBmBmBmBmBmBmmmmm#mmmm#2 .am###mmBmBmBmBmBmBmmmmm#mmmm#2
<q###mmBmBmBmBmBmBmBmBmBmBmmBmZ` <q###mmBmBmBmBmBmBmBmBmBmBmmBmZ`
um#mmmBmBm##U##mmBmBmBmWmmBmWm#( um#mmmBmBm##U##mmBmBmBmWmmBmWm#(
.wm#mmBBmm#Y~ ~XmBmBmWmmmmmBm#e .wm#mmBBmm#Y~ ~XmBmBmWmmmmmBm#e
.dm#mmWmm#Z' ]#mBmBmmBZ!"\"\""` .dm#mmWmm#Z' ]#mBmBmmBZ!""""`
.dm#mmBmm#2` ]mmmBmBm#2 .dm#mmBmm#2` ]mmmBmBm#2
jm#mmWmm#2` dmmBmBmB#( jm#mmWmm#2` dmmBmBmB#(
)m##mBmmWZ` )##mBmBmmZ )m##mBmmWZ` )##mBmBmmZ
@ -25,5 +25,5 @@ XBmBmBmBmm6s_aum##mmBmBm&^
)ZmBmBmmmBmBmmBmB##!` )ZmBmBmmmBmBmmBmB##!`
-4U#mBmWmBmBm##2" -4U#mBmWmBmBm##2"
-!!XU##US*?"- -!!XU##US*?"-
""") ''')

View file

@ -2,9 +2,9 @@
from . import AsciiArt from . import AsciiArt
trisquel = AsciiArt(match=r'''"Trisquel"*''', color='4 6', ascii=r""" trisquel = AsciiArt(match=r'''"Trisquel"*''', color='4 6', ascii=r'''
${c1} ,o$$$o. ${c1} ,o$$$o.
,o$$Y"\""Y$$b ,o$$Y"""Y$$b
,o$$$$$$o. ,$$' , Y$$b ,o$$$$$$o. ,$$' , Y$$b
,o$$$$$$$$$$$$o. :$ b Y$$. ,o$$$$$$$$$$$$o. :$ b Y$$.
,$$"' "Y$$$$o. 'b. ,b d$$$ ,$$"' "Y$$$$o. 'b. ,b d$$$
@ -12,7 +12,7 @@ $$' .d$$$$b '$$$$o 'Y$$$Y d$$$'
$$' q' 'b '$$$$$o._ _.o$$$$' $$' q' 'b '$$$$$o._ _.o$$$$'
.$$,_ _,d$ ,$$$$$$$$$$$$${c2}$$$$Y' .$$,_ _,d$ ,$$$$$$$$$$$$${c2}$$$$Y'
${c1} '$$$$aaa$$$' .$$$$$$${c2}$$$$$$$$' ${c1} '$$$$aaa$$$' .$$$$$$${c2}$$$$$$$$'
${c1} "\"\"" ${c2}d$$$$"' ${c1} """" ${c2}d$$$$"'
d$$$' .d$$b. d$$$' .d$$b.
$$$$ .$" 'a$. $$$$ .$" 'a$.
$$$$ $b $$. $$$$ $b $$.
@ -20,5 +20,5 @@ ${c1} "\"\"" ${c2}d$$$$"'
'$$$. .$$' '$$$. .$$'
'a$$$o._.o$$a' 'a$$$o._.o$$a'
'a$$$$a' 'a$$$$a'
""") ''')

View file

@ -2,7 +2,7 @@
from . import AsciiArt from . import AsciiArt
windows95 = AsciiArt(match=r'''"Windows95"''', color='6 4 3 2 1 0', ascii=r""" windows95 = AsciiArt(match=r'''"Windows95"''', color='6 4 3 2 1 0', ascii=r'''
${c6} ___ ${c6} ___
.--=+++++=-:. .--=+++++=-:.
. _ *%@@@@@@@@@@@@@@* . _ *%@@@@@@@@@@@@@@*
@ -18,8 +18,8 @@ ${c1} " , ${c6}%@@ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@
${c1} * oo *# ${c6}" _ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@ ${c1} * oo *# ${c6}" _ ${c1}&&&&&%${c6}@@${c3}%&&&&&#${c6}@@
${c1} " , ${c6}%@@ ${c1}&&*"${c6}%@@@@@@${c3}"*%&${c6}@@ ${c1} " , ${c6}%@@ ${c1}&&*"${c6}%@@@@@@${c3}"*%&${c6}@@
.${c1} * oo *# ${c6}" _ @@@@@@@@@@@@@@@@@ .${c1} * oo *# ${c6}" _ @@@@@@@@@@@@@@@@@
*:+:.__ :+# @@@ @%#=+"\"\""\""+==%#@ *:+:.__ :+# @@@ @%#=+""""""+==%#@
"+.-#+ +%* %+" " ":@ "+.-#+ +%* %+" " ":@
" " " "
""") ''')

View file

@ -141,16 +141,20 @@ def export_distro(d: AsciiArt) -> str:
# Escape/unescape ascii # Escape/unescape ascii
ascii = d.ascii.replace("\\\\", "\\") ascii = d.ascii.replace("\\\\", "\\")
while '"""' in ascii:
ascii = 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. script = f"""# This file is automatically generated. Please do not modify.
from . import AsciiArt from . import AsciiArt
{varname} = AsciiArt(match=r'''{d.match}''', color='{d.color}', ascii=r\""" {varname} = AsciiArt(match=r'''{d.match}''', color='{d.color}', ascii=r{quotes}
{ascii} {ascii}
\""") {quotes})
""" """
write(Path(__file__).parent.parent / f'hyfetch/distros/{varname}.py', script) write(Path(__file__).parent.parent / f'hyfetch/distros/{varname}.py', script)