MCPcopy Index your code
hub / github.com/numpy/numpy / parse_def

Function parse_def

numpy/_build_utils/tempita/_tempita.py:914–941  ·  view source on GitHub ↗
(tokens, name, context)

Source from the content-addressed store, hash-verified

912
913
914def parse_def(tokens, name, context):
915 first, start = tokens[0]
916 tokens = tokens[1:]
917 assert first.startswith("def ")
918 first = first.split(None, 1)[1]
919 first = first.removesuffix(":")
920 if "(" not in first:
921 func_name = first
922 sig = ((), None, None, {})
923 elif not first.endswith(")"):
924 raise TemplateError(
925 f"Function definition doesn't end with ): {first}",
926 position=start,
927 name=name,
928 )
929 else:
930 first = first[:-1]
931 func_name, sig_text = first.split("(", 1)
932 sig = parse_signature(sig_text, name, start)
933 context = context + ("def",)
934 content = []
935 while 1:
936 if not tokens:
937 raise TemplateError("Missing {{enddef}}", position=start, name=name)
938 if isinstance(tokens[0], tuple) and tokens[0][0] == "enddef":
939 return ("def", start, func_name, sig, content), tokens[1:]
940 next_chunk, tokens = parse_expr(tokens, name, context)
941 content.append(next_chunk)
942
943
944def parse_signature(sig_text, name, pos):

Callers 1

parse_exprFunction · 0.85

Calls 6

TemplateErrorClass · 0.85
parse_signatureFunction · 0.85
parse_exprFunction · 0.85
startswithMethod · 0.80
splitMethod · 0.80
endswithMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…