Helper function for break/clear parsing -- may be overridden. lookupmodule() translates (possibly incomplete) file or module name into an absolute file name. filename could be in format of: * an absolute path like '/path/to/file.py' * a relative path
(self, filename)
| 2536 | # other helper functions |
| 2537 | |
| 2538 | def lookupmodule(self, filename): |
| 2539 | """Helper function for break/clear parsing -- may be overridden. |
| 2540 | |
| 2541 | lookupmodule() translates (possibly incomplete) file or module name |
| 2542 | into an absolute file name. |
| 2543 | |
| 2544 | filename could be in format of: |
| 2545 | * an absolute path like '/path/to/file.py' |
| 2546 | * a relative path like 'file.py' or 'dir/file.py' |
| 2547 | * a module name like 'module' or 'package.module' |
| 2548 | |
| 2549 | files and modules will be searched in sys.path. |
| 2550 | """ |
| 2551 | if not filename.endswith('.py'): |
| 2552 | # A module is passed in so convert it to equivalent file |
| 2553 | filename = filename.replace('.', os.sep) + '.py' |
| 2554 | |
| 2555 | if os.path.isabs(filename): |
| 2556 | if os.path.exists(filename): |
| 2557 | return filename |
| 2558 | return None |
| 2559 | |
| 2560 | for dirname in sys.path: |
| 2561 | while os.path.islink(dirname): |
| 2562 | dirname = os.readlink(dirname) |
| 2563 | fullname = os.path.join(dirname, filename) |
| 2564 | if os.path.exists(fullname): |
| 2565 | return fullname |
| 2566 | return None |
| 2567 | |
| 2568 | def _run(self, target: _ExecutableTarget): |
| 2569 | # When bdb sets tracing, a number of call and line events happen |