MCPcopy Index your code
hub / github.com/python/cpython / file_line_helper

Function file_line_helper

Lib/idlelib/outwin.py:30–55  ·  view source on GitHub ↗

Extract file name and line number from line of text. Check if line of text contains one of the file/line patterns. If it does and if the file and line are valid, return a tuple of the file name and line number. If it doesn't match or if the file or line is invalid, return None.

(line)

Source from the content-addressed store, hash-verified

28
29
30def file_line_helper(line):
31 """Extract file name and line number from line of text.
32
33 Check if line of text contains one of the file/line patterns.
34 If it does and if the file and line are valid, return
35 a tuple of the file name and line number. If it doesn't match
36 or if the file or line is invalid, return None.
37 """
38 if not file_line_progs:
39 compile_progs()
40 for prog in file_line_progs:
41 match = prog.search(line)
42 if match:
43 filename, lineno = match.group(1, 2)
44 try:
45 f = open(filename)
46 f.close()
47 break
48 except OSError:
49 continue
50 else:
51 return None
52 try:
53 return filename, int(lineno)
54 except TypeError:
55 return None
56
57
58class OutputWindow(EditorWindow):

Callers 1

goto_file_lineMethod · 0.85

Calls 5

compile_progsFunction · 0.85
openFunction · 0.50
searchMethod · 0.45
groupMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…