MCPcopy
hub / github.com/rocky/python-uncompyle6 / build_param

Function build_param

uncompyle6/semantics/make_function2.py:42–61  ·  view source on GitHub ↗

build parameters: - handle defaults - handle format tuple parameters

(ast, name, default)

Source from the content-addressed store, hash-verified

40 """
41
42 def build_param(ast, name, default):
43 """build parameters:
44 - handle defaults
45 - handle format tuple parameters
46 """
47 # if formal parameter is a tuple, the parameter name
48 # starts with a dot (eg. '.1', '.2')
49 if name.startswith("."):
50 # replace the name with the tuple-string
51 name = self.get_tuple_parameter(ast, name)
52 pass
53
54 if default:
55 value = self.traverse(default, indent="")
56 result = "%s=%s" % (name, value)
57 if result[-2:] == "= ": # default was 'LOAD_CONST None'
58 result += "None"
59 return result
60 else:
61 return name
62
63 # MAKE_FUNCTION_... or MAKE_CLOSURE_...
64 assert node[-1].kind.startswith("MAKE_")

Callers 1

make_function2Function · 0.70

Calls 2

get_tuple_parameterMethod · 0.80
traverseMethod · 0.45

Tested by

no test coverage detected