| 16 | |
| 17 | |
| 18 | class Reader(ResourceReader): |
| 19 | def __init__(self, **kwargs): |
| 20 | vars(self).update(kwargs) |
| 21 | |
| 22 | def get_resource_reader(self, package): |
| 23 | return self |
| 24 | |
| 25 | def open_resource(self, path): |
| 26 | self._path = path |
| 27 | if isinstance(self.file, Exception): |
| 28 | raise self.file |
| 29 | return self.file |
| 30 | |
| 31 | def resource_path(self, path_): |
| 32 | self._path = path_ |
| 33 | if isinstance(self.path, Exception): |
| 34 | raise self.path |
| 35 | return self.path |
| 36 | |
| 37 | def is_resource(self, path_): |
| 38 | self._path = path_ |
| 39 | if isinstance(self.path, Exception): |
| 40 | raise self.path |
| 41 | |
| 42 | def part(entry): |
| 43 | return entry.split('/') |
| 44 | |
| 45 | return any( |
| 46 | len(parts) == 1 and parts[0] == path_ for parts in map(part, self._contents) |
| 47 | ) |
| 48 | |
| 49 | def contents(self): |
| 50 | if isinstance(self.path, Exception): |
| 51 | raise self.path |
| 52 | yield from self._contents |
| 53 | |
| 54 | |
| 55 | def create_package_from_loader(loader, is_package=True): |
no outgoing calls
no test coverage detected
searching dependent graphs…