Return True if filename points to a Python file.
(filename)
| 72 | |
| 73 | |
| 74 | def isPythonFile(filename): |
| 75 | """Return True if filename points to a Python file.""" |
| 76 | if filename.endswith('.py'): |
| 77 | return True |
| 78 | |
| 79 | # Avoid obvious Emacs backup files |
| 80 | if filename.endswith("~"): |
| 81 | return False |
| 82 | |
| 83 | max_bytes = 128 |
| 84 | |
| 85 | try: |
| 86 | with open(filename, 'rb') as f: |
| 87 | text = f.read(max_bytes) |
| 88 | if not text: |
| 89 | return False |
| 90 | except OSError: |
| 91 | return False |
| 92 | |
| 93 | return PYTHON_SHEBANG_REGEX.match(text) |
| 94 | |
| 95 | |
| 96 | def iterSourceCode(paths): |
no outgoing calls
no test coverage detected
searching dependent graphs…