Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/fsspec/__init__.py: 63%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from . import caching
2from .callbacks import Callback
3from .compression import available_compressions
4from .core import get_fs_token_paths, open, open_files, open_local, url_to_fs
5from .exceptions import FSTimeoutError
6from .mapping import FSMap, get_mapper
7from .registry import (
8 available_protocols,
9 filesystem,
10 get_filesystem_class,
11 register_implementation,
12 registry,
13)
14from .spec import AbstractFileSystem
16try:
17 from ._version import __version__ # noqa: F401
18except ImportError:
19 __version__ = "unknown"
21__all__ = [
22 "AbstractFileSystem",
23 "FSTimeoutError",
24 "FSMap",
25 "filesystem",
26 "register_implementation",
27 "get_filesystem_class",
28 "get_fs_token_paths",
29 "get_mapper",
30 "open",
31 "open_files",
32 "open_local",
33 "registry",
34 "caching",
35 "Callback",
36 "available_protocols",
37 "available_compressions",
38 "url_to_fs",
39]
42def process_entries():
43 try:
44 from importlib.metadata import entry_points
45 except ImportError:
46 return
47 if entry_points is not None:
48 try:
49 eps = entry_points()
50 except TypeError:
51 pass # importlib-metadata < 0.8
52 else:
53 if hasattr(eps, "select"): # Python 3.10+ / importlib_metadata >= 3.9.0
54 specs = eps.select(group="fsspec.specs")
55 else:
56 specs = eps.get("fsspec.specs", [])
57 registered_names = {}
58 for spec in specs:
59 err_msg = f"Unable to load filesystem from {spec}"
60 name = spec.name
61 if name in registered_names:
62 continue
63 registered_names[name] = True
64 register_implementation(
65 name,
66 spec.value.replace(":", "."),
67 errtxt=err_msg,
68 # We take our implementations as the ones to overload with if
69 # for some reason we encounter some, may be the same, already
70 # registered
71 clobber=True,
72 )
75process_entries()