MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / replace

Method replace

tools/python-3.11.9-amd64/Lib/lib2to3/pytree.py:101–122  ·  view source on GitHub ↗

Replace this node with a new one in the parent.

(self, new)

Source from the content-addressed store, hash-verified

99 raise NotImplementedError
100
101 def replace(self, new):
102 """Replace this node with a new one in the parent."""
103 assert self.parent is not None, str(self)
104 assert new is not None
105 if not isinstance(new, list):
106 new = [new]
107 l_children = []
108 found = False
109 for ch in self.parent.children:
110 if ch is self:
111 assert not found, (self.parent.children, self, new)
112 if new is not None:
113 l_children.extend(new)
114 found = True
115 else:
116 l_children.append(ch)
117 assert found, (self.children, self, new)
118 self.parent.changed()
119 self.parent.children = l_children
120 for x in new:
121 x.parent = self.parent
122 self.parent = None
123
124 def get_lineno(self):
125 """Return the line number which generated the invocant node."""

Callers 15

uu_encodeFunction · 0.45
search_functionFunction · 0.45
quoteFunction · 0.45
__init__Method · 0.45
header_decodeFunction · 0.45
_qencodeFunction · 0.45
unquoteFunction · 0.45
localtimeFunction · 0.45
decode_qFunction · 0.45
quote_stringFunction · 0.45
quoteMethod · 0.45
add_headerMethod · 0.45

Calls 4

strFunction · 0.85
changedMethod · 0.80
extendMethod · 0.45
appendMethod · 0.45

Tested by 6

test_replaceMethod · 0.36
make_local_pathFunction · 0.36
_splitdriveMethod · 0.36
test_long_descriptionMethod · 0.36