Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2..../compiler
File: misc.py
[0] Fix | Delete
def flatten(tup):
[1] Fix | Delete
elts = []
[2] Fix | Delete
for elt in tup:
[3] Fix | Delete
if isinstance(elt, tuple):
[4] Fix | Delete
elts = elts + flatten(elt)
[5] Fix | Delete
else:
[6] Fix | Delete
elts.append(elt)
[7] Fix | Delete
return elts
[8] Fix | Delete
[9] Fix | Delete
class Set:
[10] Fix | Delete
def __init__(self):
[11] Fix | Delete
self.elts = {}
[12] Fix | Delete
def __len__(self):
[13] Fix | Delete
return len(self.elts)
[14] Fix | Delete
def __contains__(self, elt):
[15] Fix | Delete
return elt in self.elts
[16] Fix | Delete
def add(self, elt):
[17] Fix | Delete
self.elts[elt] = elt
[18] Fix | Delete
def elements(self):
[19] Fix | Delete
return self.elts.keys()
[20] Fix | Delete
def has_elt(self, elt):
[21] Fix | Delete
return elt in self.elts
[22] Fix | Delete
def remove(self, elt):
[23] Fix | Delete
del self.elts[elt]
[24] Fix | Delete
def copy(self):
[25] Fix | Delete
c = Set()
[26] Fix | Delete
c.elts.update(self.elts)
[27] Fix | Delete
return c
[28] Fix | Delete
[29] Fix | Delete
class Stack:
[30] Fix | Delete
def __init__(self):
[31] Fix | Delete
self.stack = []
[32] Fix | Delete
self.pop = self.stack.pop
[33] Fix | Delete
def __len__(self):
[34] Fix | Delete
return len(self.stack)
[35] Fix | Delete
def push(self, elt):
[36] Fix | Delete
self.stack.append(elt)
[37] Fix | Delete
def top(self):
[38] Fix | Delete
return self.stack[-1]
[39] Fix | Delete
def __getitem__(self, index): # needed by visitContinue()
[40] Fix | Delete
return self.stack[index]
[41] Fix | Delete
[42] Fix | Delete
MANGLE_LEN = 256 # magic constant from compile.c
[43] Fix | Delete
[44] Fix | Delete
def mangle(name, klass):
[45] Fix | Delete
if not name.startswith('__'):
[46] Fix | Delete
return name
[47] Fix | Delete
if len(name) + 2 >= MANGLE_LEN:
[48] Fix | Delete
return name
[49] Fix | Delete
if name.endswith('__'):
[50] Fix | Delete
return name
[51] Fix | Delete
try:
[52] Fix | Delete
i = 0
[53] Fix | Delete
while klass[i] == '_':
[54] Fix | Delete
i = i + 1
[55] Fix | Delete
except IndexError:
[56] Fix | Delete
return name
[57] Fix | Delete
klass = klass[i:]
[58] Fix | Delete
[59] Fix | Delete
tlen = len(klass) + len(name)
[60] Fix | Delete
if tlen > MANGLE_LEN:
[61] Fix | Delete
klass = klass[:MANGLE_LEN-tlen]
[62] Fix | Delete
[63] Fix | Delete
return "_%s%s" % (klass, name)
[64] Fix | Delete
[65] Fix | Delete
def set_filename(filename, tree):
[66] Fix | Delete
"""Set the filename attribute to filename on every node in tree"""
[67] Fix | Delete
worklist = [tree]
[68] Fix | Delete
while worklist:
[69] Fix | Delete
node = worklist.pop(0)
[70] Fix | Delete
node.filename = filename
[71] Fix | Delete
worklist.extend(node.getChildNodes())
[72] Fix | Delete
[73] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function