Exemple #1
0
 def __init__(self, account_name: str, container_name: str,
              account_key: str):
     AbstractFileSystem.__init__(self)
     self.account_name = account_name
     self.account_key = account_key
     self.container_name = container_name
     self.do_connect()
Exemple #2
0
 def __init__(self, tenant_id, client_id, client_secret, store_name):
     AbstractFileSystem.__init__(self)
     self.tenant_id = tenant_id
     self.client_id = client_id
     self.client_secret = client_secret
     self.store_name = store_name
     self.do_connect()
Exemple #3
0
 def __init__(self,
              simple_links=True,
              block_size=None,
              same_scheme=True,
              size_policy=None,
              **storage_options):
     """
     Parameters
     ----------
     block_size: int
         Blocks to read bytes; if 0, will default to raw requests file-like
         objects instead of HTTPFile instances
     simple_links: bool
         If True, will consider both HTML <a> tags and anything that looks
         like a URL; if False, will consider only the former.
     same_scheme: True
         When doing ls/glob, if this is True, only consider paths that have
         http/https matching the input URLs.
     size_policy: this argument is deprecated
     storage_options: key-value
         May be credentials, e.g., `{'auth': ('username', 'pword')}` or any
         other parameters passed on to requests
     """
     AbstractFileSystem.__init__(self)
     self.block_size = block_size if block_size is not None else DEFAULT_BLOCK_SIZE
     self.simple_links = simple_links
     self.same_schema = same_scheme
     self.kwargs = storage_options
     self.session = requests.Session()
Exemple #4
0
 def __init__(self, fo="", mode="r", **storage_options):
     """
     Parameters
     ----------
     fo: str or file-like
         Contains ZIP, and must exist. If a str, will fetch file using
         `open_files()`, which must return one file exactly.
     mode: str
         Currently, only 'r' accepted
     storage_options: key-value
         May be credentials, e.g., `{'auth': ('username', 'pword')}` or any
         other parameters for requests
     """
     AbstractFileSystem.__init__(self)
     if mode != "r":
         raise ValueError("Only read from zip files accepted")
     self.in_fo = fo
     if isinstance(fo, str):
         files = open_files(fo)
         if len(files) != 1:
             raise ValueError('Path "{}" did not resolve to exactly'
                              'one file: "{}"'.format(fo, files))
         fo = files[0]
     self.fo = fo.__enter__()  # the whole instance is a context
     self.zip = zipfile.ZipFile(self.fo)
     self.block_size = storage_options.pop("block_size", DEFAULT_BLOCK_SIZE)
     self.kwargs = storage_options
     self.dir_cache = None
Exemple #5
0
    def __init__(
        self,
        account_name: str,
        account_key: str = None,
        connection_string: str = None,
        credential: str = None,
        sas_token: str = None,
        request_session=None,
        socket_timeout: int = None,
        blocksize: int = create_configuration(
            storage_sdk="blob").max_block_size,
        client_id: str = None,
        client_secret: str = None,
        tenant_id: str = None,
    ):
        AbstractFileSystem.__init__(self)
        self.account_name = account_name
        self.account_key = account_key
        self.connection_string = connection_string
        self.credential = credential
        self.sas_token = sas_token
        self.request_session = request_session
        self.socket_timeout = socket_timeout
        self.blocksize = blocksize
        self.client_id = client_id
        self.client_secret = client_secret
        self.tenant_id = tenant_id

        if (self.credential is None and self.account_key is None
                and self.sas_token is None and self.client_id is not None):
            self.credential = self._get_credential_from_service_principal()
        self.do_connect()
Exemple #6
0
 def __init__(
     self,
     account_name: str,
     account_key: str = None,
     custom_domain: str = None,
     is_emulated: bool = False,
     sas_token: str = None,
     protocol=DEFAULT_PROTOCOL,
     endpoint_suffix=SERVICE_HOST_BASE,
     request_session=None,
     connection_string: str = None,
     socket_timeout=None,
     token_credential=None,
     blocksize=BlockBlobService.MAX_BLOCK_SIZE,
 ):
     AbstractFileSystem.__init__(self)
     self.account_name = account_name
     self.account_key = account_key
     self.custom_domain = custom_domain
     self.is_emulated = is_emulated
     self.sas_token = sas_token
     self.protocol = protocol
     self.endpoint_suffix = endpoint_suffix
     self.request_session = request_session
     self.connection_string = connection_string
     self.socket_timeout = socket_timeout
     self.token_credential = token_credential
     self.blocksize = blocksize
     self.do_connect()
Exemple #7
0
 def __init__(
     self,
     account_name: str,
     container_name: str,
     account_key: str,
     custom_domain: str = None,
     is_emulated: bool = False,
 ):
     AbstractFileSystem.__init__(self)
     self.account_name = account_name
     self.account_key = account_key
     self.container_name = container_name
     self.custom_domain = custom_domain
     self.is_emulated = is_emulated
     self.do_connect()
Exemple #8
0
 def __init__(self, **storage_options):
     """
     Parameters
     ----------
     block_size: int
         Blocks to read bytes; if 0, will default to raw requests file-like
         objects instead of HTTPFile instances
     simple_links: bool
         If True, will consider both HTML <a> tags and anything that looks
         like a URL; if False, will consider only the former.
     storage_options: key-value
         May be credentials, e.g., `{'auth': ('username', 'pword')}` or any
         other parameters passed on to requests
     """
     AbstractFileSystem.__init__(self)
     self.block_size = storage_options.pop('block_size', DEFAULT_BLOCK_SIZE)
     self.simple_links = storage_options.pop('simple_links', True)
     self.kwargs = storage_options
     self.session = requests.Session()
Exemple #9
0
    def __init__(self,
                 simple_links=True,
                 block_size=None,
                 same_scheme=True,
                 size_policy=None,
                 cache_type="bytes",
                 cache_options=None,
                 asynchronous=False,
                 loop=None,
                 **storage_options):
        """
        NB: if this is called async, you must await set_client

        Parameters
        ----------
        block_size: int
            Blocks to read bytes; if 0, will default to raw requests file-like
            objects instead of HTTPFile instances
        simple_links: bool
            If True, will consider both HTML <a> tags and anything that looks
            like a URL; if False, will consider only the former.
        same_scheme: True
            When doing ls/glob, if this is True, only consider paths that have
            http/https matching the input URLs.
        size_policy: this argument is deprecated
        storage_options: key-value
            May be credentials, e.g., `{'auth': ('username', 'pword')}` or any
            other parameters passed on to requests
        cache_type, cache_options: defaults used in open
        """
        AbstractFileSystem.__init__(self, asynchronous=asynchronous, loop=loop)
        self.block_size = block_size if block_size is not None else DEFAULT_BLOCK_SIZE
        self.simple_links = simple_links
        self.same_schema = same_scheme
        self.cache_type = cache_type
        self.cache_options = cache_options
        self.kwargs = storage_options
        if not asynchronous:
            self._session = sync(self.loop, get_client)
            weakref.finalize(self, sync, self.loop, self.session.close)
        else:
            self._session = None