Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.
/ pycosio Public archive

Commit

Permalink
Keep extra_url_prefix with prefixes in system
Browse files Browse the repository at this point in the history
  • Loading branch information
JGoutin committed Aug 24, 2018
1 parent 4da2528 commit c108498
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
18 changes: 16 additions & 2 deletions pycosio/_core/io_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion pycosio/_core/storage_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c108498

Please sign in to comment.