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

Class Node

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

Concrete implementation for interior nodes.

Source from the content-addressed store, hash-verified

205 return str(self).encode("ascii")
206
207class Node(Base):
208
209 """Concrete implementation for interior nodes."""
210
211 def __init__(self,type, children,
212 context=None,
213 prefix=None,
214 fixers_applied=None):
215 """
216 Initializer.
217
218 Takes a type constant (a symbol number >= 256), a sequence of
219 child nodes, and an optional context keyword argument.
220
221 As a side effect, the parent pointers of the children are updated.
222 """
223 assert type >= 256, type
224 self.type = type
225 self.children = list(children)
226 for ch in self.children:
227 assert ch.parent is None, repr(ch)
228 ch.parent = self
229 if prefix is not None:
230 self.prefix = prefix
231 if fixers_applied:
232 self.fixers_applied = fixers_applied[:]
233 else:
234 self.fixers_applied = None
235
236 def __repr__(self):
237 """Return a canonical string representation."""
238 return "%s(%s, %r)" % (self.__class__.__name__,
239 type_repr(self.type),
240 self.children)
241
242 def __unicode__(self):
243 """
244 Return a pretty string representation.
245
246 This reproduces the input source exactly.
247 """
248 return "".join(map(str, self.children))
249
250 if sys.version_info > (3, 0):
251 __str__ = __unicode__
252
253 def _eq(self, other):
254 """Compare two nodes for equality."""
255 return (self.type, self.children) == (other.type, other.children)
256
257 def clone(self):
258 """Return a cloned (deep) copy of self."""
259 return Node(self.type, [ch.clone() for ch in self.children],
260 fixers_applied=self.fixers_applied)
261
262 def post_order(self):
263 """Return a post-order iterator for the tree."""
264 for child in self.children:

Callers 15

assertStrMethod · 0.90
KeywordArgFunction · 0.70
AssignFunction · 0.70
AttrFunction · 0.70
ArgListFunction · 0.70
CallFunction · 0.70
SubscriptFunction · 0.70
ListCompFunction · 0.70
FromImportFunction · 0.70
ImportAndCallFunction · 0.70
parenthesizeFunction · 0.70
make_suiteFunction · 0.70

Calls

no outgoing calls

Tested by 1

assertStrMethod · 0.72