diff --git a/pycosio/_core/io_system.py b/pycosio/_core/io_system.py index 123863b..0c30839 100644 --- a/pycosio/_core/io_system.py +++ b/pycosio/_core/io_system.py @@ -20,9 +20,10 @@ class SystemBase(ABC): Generally, client configuration and credentials. unsecure (bool): If True, disables TLS/SSL to improves transfer performance. But makes connection unsecure. + prefixes (tuple): Tuple of prefixes to force use. """ - def __init__(self, storage_parameters=None, unsecure=False): + def __init__(self, storage_parameters=None, unsecure=False, prefixes=None): # Save storage parameters self._storage_parameters = storage_parameters or dict() self._unsecure = unsecure @@ -31,7 +32,10 @@ def __init__(self, storage_parameters=None, unsecure=False): self._client = None # Initialize prefixes - self._prefixes = self._get_prefixes() + if prefixes: + self._prefixes = prefixes + else: + self._prefixes = self._get_prefixes() @property def client(self): @@ -211,6 +215,16 @@ def prefixes(self): """ return self._prefixes + @prefixes.setter + def prefixes(self, prefixes): + """ + Set URL prefixes for this storage. + + Args: + prefixes (tuple of str): URL prefixes + """ + self._prefixes = prefixes + def relpath(self, path): """ Get path relative to storage. diff --git a/pycosio/_core/storage_manager.py b/pycosio/_core/storage_manager.py index 455e941..c4d6e27 100644 --- a/pycosio/_core/storage_manager.py +++ b/pycosio/_core/storage_manager.py @@ -72,7 +72,8 @@ def get_instance(name, cls='system', storage=None, storage_parameters=None, if same_parameters: return info['system_cached'] else: - return info['system'](**system_parameters) + return info['system']( + prefixes=info['prefixes'], **system_parameters) # Returns other classes if same_parameters: @@ -145,6 +146,8 @@ def mount(storage=None, name='', storage_parameters=None, if extra_url_prefix: prefixes = list(prefixes) prefixes.append(extra_url_prefix) + prefixes = tuple(prefixes) + storage_info['system_cached'].prefixes = storage_info['prefixes'] = prefixes # Mounts with _MOUNT_LOCK: