MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / is_valid_py_file

Function is_valid_py_file

pydev_coverage.py:6–21  ·  view source on GitHub ↗

Checks whether the file can be read by the coverage module. This is especially needed for .pyx files and .py files with syntax errors.

(path)

Source from the content-addressed store, hash-verified

4
5
6def is_valid_py_file(path):
7 """
8 Checks whether the file can be read by the coverage module. This is especially
9 needed for .pyx files and .py files with syntax errors.
10 """
11 import os
12
13 is_valid = False
14 if os.path.isfile(path) and not os.path.splitext(path)[1] == ".pyx":
15 try:
16 with open(path, "rb") as f:
17 compile(f.read(), path, "exec")
18 is_valid = True
19 except:
20 pass
21 return is_valid
22
23
24def execute():

Callers 1

executeFunction · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected