def _register_filesystems(only_available=False): """Search for python packages supporting remote filesystems.""" from fsspec.registry import known_implementations impls = known_implementations.items() r = w = 0 for protocol, spec in impls: if "err" in spec: emsg = "# WARN: fsspec {} unavailable: {}".format(protocol, spec["err"]) logger.warning(emsg) if only_available: # otherwise foward the exception on first use when the # handler can show what package is missing continue # when missing a package for fsspec use the available source in petl # E.g: fsspec requires `requests` package installed for handling http and https reader = get_reader(protocol) if not "err" in spec or reader is None: register_reader(protocol, RemoteSource) r += 1 writer = get_writer(protocol) if not "err" in spec or writer is None: register_writer(protocol, RemoteSource) w += 1 dlog = "# fsspec: registered {} remote readers and {} remote writers" logger.debug(dlog.format(r, w))
def _register_filesystems_from(fsspec_registry, only_available): """Register each fsspec provider from this registry as remote source.""" for protocol, spec in fsspec_registry.items(): missing_deps = "err" in spec if missing_deps and only_available: # this could lead to only buit-in implementations available # Other Known Implementations are reported with 'err' even even # the package is installed continue # When missing a package for fsspec use the available source in petl # E.g: fsspec requires `requests` package installed for handling http and https # but petl has URLSource that can work with urlib has_reader = get_reader(protocol) if not missing_deps or has_reader is None: register_reader(protocol, RemoteSource) has_writer = get_writer(protocol) if not missing_deps or has_writer is None: register_writer(protocol, RemoteSource)
def _register_filesystems(only_available=False): """Search for python packages supporting remote filesystems.""" from fsspec.registry import known_implementations impls = known_implementations.items() q = 0 for protocol, spec in impls: # use the available for for compatibility reasons until next spring cleaning if protocol.startswith("http"): continue if "err" in spec: emsg = "# WARN: fsspec {} unavailable: {}".format(protocol, spec["err"]) logger.warning(emsg) if only_available: continue register_reader(protocol, RemoteSource) register_writer(protocol, RemoteSource) q += 1 logger.debug("# fsspec: registered {} providers".format(q))
if not url: raise ValueError("SMB error: no host given") elif not url.startswith("smb://"): raise ValueError(e + url) if PY3: from urllib.parse import urlparse else: from urlparse import urlparse parsed = urlparse(url) if not parsed.path: raise ValueError(e + url) unc_path = parsed.path.replace("/", "\\") server_path = "\\\\{}{}".format(parsed.hostname, unc_path) if not parsed.username: domain, username = None elif ";" in parsed.username: domain, username = parsed.username.split(";") else: domain, username = None, parsed.username port = 445 if not parsed.port else int(parsed.port) return domain, parsed.hostname, port, username, parsed.password, server_path register_reader("smb", SMBSource) register_writer("smb", SMBSource) # endregion