Factory for physical package reader objects.
| 8 | |
| 9 | |
| 10 | class PhysPkgReader: |
| 11 | """Factory for physical package reader objects.""" |
| 12 | |
| 13 | def __new__(cls, pkg_file): |
| 14 | # if `pkg_file` is a string, treat it as a path |
| 15 | if isinstance(pkg_file, str): |
| 16 | if os.path.isdir(pkg_file): |
| 17 | reader_cls = _DirPkgReader |
| 18 | elif is_zipfile(pkg_file): |
| 19 | reader_cls = _ZipPkgReader |
| 20 | else: |
| 21 | raise PackageNotFoundError("Package not found at '%s'" % pkg_file) |
| 22 | else: # assume it's a stream and pass it to Zip reader to sort out |
| 23 | reader_cls = _ZipPkgReader |
| 24 | |
| 25 | return super(PhysPkgReader, cls).__new__(reader_cls) |
| 26 | |
| 27 | |
| 28 | class PhysPkgWriter: |
no outgoing calls
searching dependent graphs…