MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / full_name_node

Function full_name_node

tensorflow/tools/compatibility/ast_edits.py:47–67  ·  view source on GitHub ↗

Make an Attribute or Name node for name. Translate a qualified name into nested Attribute nodes (and a Name node). Args: name: The name to translate to a node. ctx: What context this name is used in. Defaults to Load() Returns: A Name or Attribute node.

(name, ctx=ast.Load())

Source from the content-addressed store, hash-verified

45
46
47def full_name_node(name, ctx=ast.Load()):
48 """Make an Attribute or Name node for name.
49
50 Translate a qualified name into nested Attribute nodes (and a Name node).
51
52 Args:
53 name: The name to translate to a node.
54 ctx: What context this name is used in. Defaults to Load()
55
56 Returns:
57 A Name or Attribute node.
58 """
59 names = name.split(".")
60 names.reverse()
61 node = ast.Name(id=names.pop(), ctx=ast.Load())
62 while names:
63 node = ast.Attribute(value=node, attr=names.pop(), ctx=ast.Load())
64
65 # Change outermost ctx to the one given to us (inner ones should be Load).
66 node.ctx = ctx
67 return node
68
69
70def get_arg_value(node, arg_name, arg_pos=None):

Callers 1

_maybe_renameMethod · 0.85

Calls 5

LoadMethod · 0.45
splitMethod · 0.45
reverseMethod · 0.45
NameMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected