| 546 | S_IFDIR = 0o040000 |
| 547 | |
| 548 | def __init__(self, source_root): |
| 549 | self.source_root = source_root |
| 550 | self.module_path_cache = {'': set()} |
| 551 | for key, dirty_path in iter_keys(self.NAMESPACE_PREFIX): |
| 552 | # dirty_path contains unique prefix to prevent repeatable keys in the resource storage |
| 553 | path = dirty_path.split(b'/', 1)[1] |
| 554 | namespaces = find(key).split(b':') |
| 555 | for n in namespaces: |
| 556 | package_name = _s(n.rstrip(b'.')) |
| 557 | self.module_path_cache.setdefault(package_name, set()).add(_s(path)) |
| 558 | # Fill parents with default empty path set if parent doesn't exist in the cache yet |
| 559 | while package_name: |
| 560 | package_name = package_name.rpartition('.')[0] |
| 561 | if package_name in self.module_path_cache: |
| 562 | break |
| 563 | self.module_path_cache.setdefault(package_name, set()) |
| 564 | for package_name in self.module_path_cache.keys(): |
| 565 | self._add_parent_dirs(package_name, visited=set()) |
| 566 | |
| 567 | def get_module_path(self, fullname): |
| 568 | """ |