Created
June 9, 2020 09:52
-
-
Save vient/27800c8a2d4fd1d9651fc8eece88b6bf to your computer and use it in GitHub Desktop.
Python abomination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import ๐๐ถ๐ด | |
import ๐๐บ๐ซโ om | |
import ๐๐ต๐ป๐พ๐๐ | |
import ๏ฝ๐ฏ๐๏ฝ๐ ๐น๏ฝ ๐ฝ๐๐ฅ๐ | |
from ๏ฝ๐ถ๐จ๏ฝ๐๐ฃt๐ import โโ โโ๏ฝลฟ as L๐ฆ๐๐แตฃ๐ฌ | |
๐๐ก๐ด๐ช๏ผฏ๐ซโฐ_๐พ๐ด๐ฒโ๐๐พ = {} | |
def ๐ง๐๐ต๐ญ_๏ฝ๐ฃโฑ๐๐de_๐ท๐๐ฆ๐๐ค(): | |
global ๐โโโญ๐ข๐๐ธ_๐ช๐๐ข๐๐ผ๐ | |
๐a๐๏ฝ ๐ = {} | |
for ๐พ in ๐ณa๐ท๐จ๐(0x110000): | |
try: | |
๐๐ขแต๐๐[๐ข] = แตค๐ป๐ฒ๐๐ ๐ญ๐ฎ๐๐ข๐๏ฝ.n๐ถ๐ถ๐(๐ฌ๏ฝ๐ง(๐)) | |
except ๐ผ๐ฑ๐ค๐๐ญ๏ฝ๐โ๐: | |
continue | |
๐ผ๐ญ๐๐ถ๐๐ป๐_C๐ผโญแดด๐ค๐ฒ['names'] = ๐ฃ๐๐ถแต๐ | |
for ๐ in ๐ฌ๐ญ๐ซ๐พ๐๐ด.๐๐ด๐ ๐แตข_โ๐๐ธ๐๐๐ธแต๐โ: | |
๏ฝ๐ฒ๐ = ๏ฝโ๐_๐โ ๐ถ๏ฝหก๐ฎ๐_๐ฌโ๐ช๐โ(๐, ๐.๐แต๐๐๐ง(), 'SMALL') | |
for ๐น in ๐๐ฎ๐จ: | |
๐๐โ๐ขแดผโ ๐ค_C๐ธ๐๏ผจ๐๐พ[๐ต] = ๏ฝ๐พโ | |
for ๐ธ in ๏ฝ๐ตแตฃ๐ถ๐๐ .๏ฝ๐ค๐ ๐๐ข_๐ข๐ฝ๐น๐๐๐๐๐e: | |
๐๐ฒ๐ = ๐๐ข๐_sแตข๐๐ฆ๏ฝ๐ถ๐ณ_แถ๐๐๐๐(๐ค, ๐, 'CAPITAL') | |
for x in ๐ฏ๐๐จ: | |
๐ผแดบ๐๐๏ผฏ๐ท๐_๐๐โญ๐๐ธ๐ฎ[๏ฝ] = ๐ฃโฏโ | |
def ๐๐ฎ๐ฉ_๐ด๐ฆโ๐ข๐ญ๐๐_๐ผ๐๐๐๐ด(๐๐ฅ๐ผ๐๐๏ฝ_๐๐พ_๐๐๐บแตฃโฟ๐m๐, ๐ขn๐๐ผ๐ผ๏ฝโฏ_๏ฝh๐๐๐ป๐แต๏ฝ =None, ๐๐พ๐ฅ๐ฅ๐๐ฏ_๐ ๐๐ฆ๏ฝแต๐๐ฅ=None): | |
if 'names' not in ๏ผต๐๐๐๐ช๏ผคแดฑ_๐๐๐๐แดฑ๐พ: | |
๐๏ฝl๐_๐๐ฃ๐๏ฝโ๐ e_๐ฃ๐๐ฎ๐ฒ๐() | |
๐ป๐๐๐พ๐ = ๐ค๐โโ๐๐ฟ๐_๐ช๐ผ๐๏ผจ๐ฌ๐ฒ['names'] | |
แถ ๐l๐ต๐ฆ๐ง๐๐ = ๐๐ช๐๐๏ฝ | |
if ๐๐ท๐๐๐๐๐_c๐๐บสณ๐ง๐ช๐ข๐พ: | |
๐๐๐๐ญ๐ฒ๐ณแต๐น = [โฑ for ๐ข in ๐ณ๐โ๐ฝ๐๐๐๐น if แตค๐๐๐โด๐กโ_๐๐๐ข๐๐๏ฝ๐๐ in ๐ฃ๏ฝ๐๐พ๐[๐].๐๐๐ต๐๐ต()] | |
if ๐โ ๏ฝ๐ญแต๐_๐๐๐ฒ๐๐ค๐๐ญ: | |
๐๐ฒ๐๐ตe๐ง๏ฝ โ = [โ for ๐ฆ in f๐ฆหก๐ญโr๐d if f๏ฝ๐ ๐ฝ๐ฆ๐ณ_๐ธ๐ฒ๐ฒw๐ฐ๐ป๐ in ๐ป๐ช๐๐ฒ๐ฐ[๐].ลฟ๐ญ๐๐ฒ๏ฝ()] | |
๐๐๐ฎ๐ถ๐๐๐ฃ_๐ผ๐๐๐ณ๐ = [] | |
for c๐๐ก๐ฆ๐ฉ๐ฐ๏ฝ๐แต in ๐๐ฆ๐ต๐ฉ๐พ๐๐๐: | |
try: | |
โ ๐ซ๐๐ (๐๐ฅ๐(๐คโ๐ฅ๐๐ o๏ฝโ๐), {}, {}) | |
except ๐ผ๐๐๏ฝ โ๐ฅ๐พ๐ n as โ : | |
if f"'{๐๏ฝ๐๐๐ต๐_๐ซโ _๐ธ๐ฝ๐ขแตฃ๏ฝ๐๐๐}'" in ๏ฝ .๐บ๏ฝ๐๐ด[0]: | |
๐ โฑ๐ข๐โ๐๐_๐๏ฝ๐๐ป๐.๐๐ญ๐ฅ๏ฝ ๐โ (๐๐๐๐ฆ๐o๐๐ท๐ฉ) | |
return ๐ ๐m๐ถ๏ฝแต๐ฃ_c๐ฑa๐ฟs | |
def ๐๐๐ธ๐ _๐๐ต๐_๐กe๐ฉ๐ฅ_๐๐(โ): | |
global ๐โ๐โญ๐พDโฐ_๐๐จ๐ชโE๐ฆ | |
๐ซ๐พลฟ = '' | |
for ๐ in ๐: | |
if ๐๐ป๐(๏ฝ) not in U๐ฝ๐๐ฒ๐D๐ธ_๐ช๐ ๐ถโ๐๐พ: | |
๐๐ปโฑ๐๐โ ๐_๐ ๐แตแตฃ๐a๐โ = None | |
f๐ช๐๐๐๐ฃ_๐๐๐๐ฌ๐๐ฟโ = None | |
if c in ๐ ๐๐๐พ๐โ.๐๐๐โฑ๏ฝ_lโ ๐ก๐ก๐ฒ๐๐: | |
๐๐โฑ๏ฝ๐๐๐ฎ_๐ค๏ฝ๐ฎ๐ณ๐ป๐๐ฆ๐ = ๐ฐ.๐ฒแต๐โ ๐ป() | |
แถ i๐ ๐e๐_๐๐พ๐ข๐ด๐ธrd = 'SMALL' if ๐ in s๐๐๐๐ฏ๐.โ๐ผแถ๐๐ถ_๐๐๐๐ฎ๐๐a๐๐ else 'CAPITAL' | |
๐โ๐๐ฎ๐๐๐_๐๐จ๐โโฐ๐ฎ[แต๐๐ฑ(๐)] = ๐๐๐ก_๐ฌ๐๐แตข๐ก๐ช๐_๐๏ฝ๐๐ฃ๐(๐ผ, ๐ข๐ทโฑ๐ธ๐แต๐พ_๐สฐ๐๐ซ๐๐ข๐บ๐, ๐ณ๐๐๐๐ฒr_๐ ๐๐ฆ๐ โ๐ซ๐) | |
๐โฑ๐๐โ๐ข๐โ = ๐๏ผฎ๐C๐ฎ๐๐_๐๐ฐ๏ผฃ๐ณโฐ๐ข[๐ฌ๐๐ก(๐)] | |
if ๐โ๐(๐ฐi๏ฝ๐ชl๐ข๐งหข) > 0: | |
๐ฟ๐ฎ๐ฌ += ๐ฐ๐๐(๐๐๐๐ฑโ๏ฝ.๐ค๐๐คi๐ฌโ(๐i๐โ ๐ aแตฃ๐)) | |
else: | |
r๐๏ฝ += ๐ | |
return ๐๐ฎs | |
def แตแต๐๏ฝ(): | |
if ๏ฝ๐๐ง(หข๐ฆ๐.๐ฎr๐๐ณ) > 1: | |
๐ต๐x๐๐ = ๐โ๐น๐ข๐๏ฝ.gโแต_โ๐๐แต๐_๐๐ข_๐ซ๐๐แต('python3') | |
with ๐๐ญโฏ๐(หข๐๐.๐๏ฝแต๏ฝ[1], 'r', โฏ๐๐ฌ๐๐น๐๐๐='utf-8') as ๐ง: | |
๐๐ฆ๐ญt = ๐.๐ป๐๐๐() | |
๐๐๏ฝ = '' | |
for แต๐ค๐โ๐_๐โ๏ฝลฟ๐, ๐ฝ๐๐๐๐_๐ต๐พ๐๐ in ๐ญ๐๐โฏ๐ป.๐โ๐ฝ_๐ฉo๐๐๐ฏ๐จ(๐ญ๏ฝ หฃโ): | |
if ๐๐๐(แต๐ k๐๐ง_c๐๐๐จ๐ ).๐ฌ๐๐สณแต๐ผ๐๐๏ฝ๐ต('Token.Name'): | |
๐๐พ๐ฌ += ๐แตค๐ผ๐ฌ_๐ก๐๐ฒ_๐๐๐น๐_๐๐ (แต๐๐๐โ_๐แต๐๐) | |
elif ๐๐ฝ๐(แต๏ฝk๐๐ฃ_๐๐๐โ๐).๐๐๐ชแตฃ๐ฅหข๐ฐ๐ถ๐ฉ๐('Token.Literal.String.Interpol'): | |
if ':' in แต๐จ๐แต๐_๐ฝโ ๐๐: | |
๐ป๐๐ += f๏ฝ๐ธ๐_๐ฉ๐๐ฆ_โ๐หฃ๐ก_๐ฆ๐(๐กโด๐จ๐๐_๐ตโ๐ฑ๐ฅ[:๐โโ๐๐_tแต๐ฑโ.๐๐พโd(':')]) + ๐๐จ๐ค๐๐ท_โโ ๐ ๐[๐๐๐โฏ๐_๐โ ๐๐.๐โฑโฟ๐ญ(':'):] | |
else: | |
๐ฏ๐๐ += ๐ฟแต๐๏ฝ_๐๐๐ฎ_๐แตโt_๐๐(๐๐ธโโ๐ท_๐๐๐ญ๐) | |
else: | |
๐ง๐๐ += ๐ฑ๏ฝ๐ฌ๏ฝ ๐ท_๐ฅ๏ฝ x๏ฝ | |
with แต๐e๐ท('cool_' + ๐๐๐.๏ฝ๐ซ๐ฐแต[1], 'w', ๐๐๐o๐๐๐๐='utf-8') as ๐: | |
๐ฃ.๐ธri๐ฑ๐ฎ(r๐๐จ) | |
if __๏ฝa๐๐__ == '__main__': | |
๐๐โฑ๐ซ() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment