# standard imports import logging from urllib.parse import urlparse logg = logging.getLogger(__name__) def from_cache_spec(chain_spec, s): o = urlparse(s) path = '.' scheme = None if o.scheme == '': scheme = 'file' else: scheme = o.scheme if o.path != '': if o.path[0] != '/': path = os.path.join(path, o.path) else: path = o.path logg.debug('parsed scheme {} from cache spec'.format(scheme)) if scheme == 'file': from eth_cache.store.fs import FileStore return FsStore(chain_spec, cache_root=path) if scheme == 'lmdb': from eth_cache.store.lmdb import LmdbStore return LmdbStore(chain_spec, cache_root=path) return None