You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
32 lines
776 B
Python
32 lines
776 B
Python
import sys
|
|
from uncompyle6 import PYTHON3
|
|
|
|
if PYTHON3:
|
|
intern = sys.intern
|
|
from collections import UserList
|
|
else:
|
|
from UserList import UserList
|
|
|
|
|
|
class AST(UserList):
|
|
def __init__(self, type, kids=[]):
|
|
self.type = intern(type)
|
|
UserList.__init__(self, kids)
|
|
|
|
def __getslice__(self, low, high): return self.data[low:high]
|
|
|
|
def __eq__(self, o):
|
|
if isinstance(o, AST):
|
|
return self.type == o.type \
|
|
and UserList.__eq__(self, o)
|
|
else:
|
|
return self.type == o
|
|
|
|
def __hash__(self): return hash(self.type)
|
|
|
|
def __repr__(self, indent=''):
|
|
rv = str(self.type)
|
|
for k in self:
|
|
rv = rv + '\n' + str(k).replace('\n', '\n ')
|
|
return rv
|