MCPcopy Create free account
hub / github.com/RustPython/RustPython / find_function

Function find_function

Lib/pdb.py:93–104  ·  view source on GitHub ↗
(funcname, filename)

Source from the content-addressed store, hash-verified

91 "post_mortem", "help"]
92
93def find_function(funcname, filename):
94 cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname))
95 try:
96 fp = open(filename)
97 except OSError:
98 return None
99 # consumer of this info expects the first line to be 1
100 with fp:
101 for lineno, line in enumerate(fp, start=1):
102 if cre.match(line):
103 return funcname, filename, lineno
104 return None
105
106def getsourcelines(obj):
107 lines, lineno = inspect.findsource(obj)

Callers 1

lineinfoMethod · 0.85

Calls 5

enumerateFunction · 0.85
escapeMethod · 0.80
openFunction · 0.70
compileMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected