MCPcopy Create free account
hub / github.com/numpy/numpy / parse_structure

Function parse_structure

numpy/distutils/from_template.py:58–83  ·  view source on GitHub ↗

Return a list of tuples for each function or subroutine each tuple is the start and end of a subroutine or function to be expanded.

(astr)

Source from the content-addressed store, hash-verified

56function_start_re = re.compile(r'\n (\$|\*)\s*function\b', re.I)
57
58def parse_structure(astr):
59 """ Return a list of tuples for each function or subroutine each
60 tuple is the start and end of a subroutine or function to be
61 expanded.
62 """
63
64 spanlist = []
65 ind = 0
66 while True:
67 m = routine_start_re.search(astr, ind)
68 if m is None:
69 break
70 start = m.start()
71 if function_start_re.match(astr, start, m.end()):
72 while True:
73 i = astr.rfind('\n', ind, start)
74 if i==-1:
75 break
76 start = i
77 if astr[i:i+7]!='\n $':
78 break
79 start += 1
80 m = routine_end_re.search(astr, m.end())
81 ind = end = m and m.end()-1 or len(astr)
82 spanlist.append((start, end))
83 return spanlist
84
85template_re = re.compile(r"<\s*(\w[\w\d]*)\s*>")
86named_re = re.compile(r"<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>")

Callers 1

process_strFunction · 0.70

Calls 1

rfindMethod · 0.80

Tested by

no test coverage detected