| 79 | |
| 80 | |
| 81 | class CustomImporter(object): |
| 82 | def __init__(self, roots): |
| 83 | self._roots = roots |
| 84 | |
| 85 | def find_spec(self, fullname, path, target=None): |
| 86 | return None |
| 87 | |
| 88 | def find_module(self, fullname, package_path=None): |
| 89 | for path in self._roots: |
| 90 | full_path = self._get_module_path(path, fullname) |
| 91 | |
| 92 | if os.path.exists(full_path) and os.path.isdir(full_path) and not os.path.exists(os.path.join(full_path, "__init__.py")): |
| 93 | open(os.path.join(full_path, "__init__.py"), "w").close() |
| 94 | |
| 95 | return None |
| 96 | |
| 97 | def _get_module_path(self, path, fullname): |
| 98 | return os.path.join(path, *fullname.split('.')) |
| 99 | |
| 100 | |
| 101 | class YaTestLoggingFileHandler(logging.FileHandler): |