Find the filesystem paths associated with imported modules.
()
| 41 | |
| 42 | |
| 43 | def _iter_module_paths() -> t.Iterator[str]: |
| 44 | """Find the filesystem paths associated with imported modules.""" |
| 45 | # List is in case the value is modified by the app while updating. |
| 46 | for module in list(sys.modules.values()): |
| 47 | name = getattr(module, "__file__", None) |
| 48 | |
| 49 | if name is None or name.startswith(_ignore_always): |
| 50 | continue |
| 51 | |
| 52 | while not os.path.isfile(name): |
| 53 | # Zip file, find the base file without the module path. |
| 54 | old = name |
| 55 | name = os.path.dirname(name) |
| 56 | |
| 57 | if name == old: # skip if it was all directories somehow |
| 58 | break |
| 59 | else: |
| 60 | yield name |
| 61 | |
| 62 | |
| 63 | def _remove_by_pattern(paths: set[str], exclude_patterns: set[str]) -> None: |
no test coverage detected