Given a source (filename or zipfile), return an appropriate CompleteDirs subclass.
(cls, source)
| 145 | |
| 146 | @classmethod |
| 147 | def make(cls, source): |
| 148 | """ |
| 149 | Given a source (filename or zipfile), return an |
| 150 | appropriate CompleteDirs subclass. |
| 151 | """ |
| 152 | if isinstance(source, CompleteDirs): |
| 153 | return source |
| 154 | |
| 155 | if not isinstance(source, zipfile.ZipFile): |
| 156 | return cls(source) |
| 157 | |
| 158 | # Only allow for FastLookup when supplied zipfile is read-only |
| 159 | if 'r' not in source.mode: |
| 160 | cls = CompleteDirs |
| 161 | |
| 162 | source.__class__ = cls |
| 163 | return source |
| 164 | |
| 165 | @classmethod |
| 166 | def inject(cls, zf: zipfile.ZipFile) -> zipfile.ZipFile: |