%PDF- %PDF-
Direktori : /usr/lib/python3/dist-packages/fs/opener/ |
Current File : //usr/lib/python3/dist-packages/fs/opener/zipfs.py |
# coding: utf-8 """`ZipFS` opener definition. """ from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import typing from .base import Opener from .registry import registry from .errors import NotWriteable if typing.TYPE_CHECKING: from typing import Text from .parse import ParseResult from ..zipfs import ZipFS # noqa: F401 @registry.install class ZipOpener(Opener): """`ZipFS` opener. """ protocols = ["zip"] def open_fs( self, fs_url, # type: Text parse_result, # type: ParseResult writeable, # type: bool create, # type: bool cwd, # type: Text ): # type: (...) -> ZipFS from ..zipfs import ZipFS if not create and writeable: raise NotWriteable("Unable to open existing ZIP file for writing") zip_fs = ZipFS(parse_result.resource, write=create) return zip_fs