| 3 | |
| 4 | |
| 5 | def find_in_pythonpath(module_name): |
| 6 | # Check all the occurrences where we could match the given module/package in the PYTHONPATH. |
| 7 | # |
| 8 | # This is a simplistic approach, but probably covers most of the cases we're interested in |
| 9 | # (i.e.: this may fail in more elaborate cases of import customization or .zip imports, but |
| 10 | # this should be rare in general). |
| 11 | found_at = [] |
| 12 | |
| 13 | parts = module_name.split(".") # split because we need to convert mod.name to mod/name |
| 14 | for path in sys.path: |
| 15 | target = os.path.join(path, *parts) |
| 16 | target_py = target + ".py" |
| 17 | if os.path.isdir(target): |
| 18 | found_at.append(target) |
| 19 | if os.path.exists(target_py): |
| 20 | found_at.append(target_py) |
| 21 | return found_at |
| 22 | |
| 23 | |
| 24 | class DebuggerInitializationError(Exception): |