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)
| 28 | |
| 29 | |
| 30 | def 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 | |
| 58 | class OutputWindow(EditorWindow): |
no test coverage detected
searching dependent graphs…