Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/fsspec/__init__.py: 66%

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

32 statements  

1from . import caching 

2from ._version import __version__ # noqa: F401 

3from .callbacks import Callback 

4from .compression import available_compressions 

5from .core import get_fs_token_paths, open, open_files, open_local, url_to_fs 

6from .exceptions import FSTimeoutError 

7from .mapping import FSMap, get_mapper 

8from .registry import ( 

9 available_protocols, 

10 filesystem, 

11 get_filesystem_class, 

12 register_implementation, 

13 registry, 

14) 

15from .spec import AbstractFileSystem 

16 

17__all__ = [ 

18 "AbstractFileSystem", 

19 "FSTimeoutError", 

20 "FSMap", 

21 "filesystem", 

22 "register_implementation", 

23 "get_filesystem_class", 

24 "get_fs_token_paths", 

25 "get_mapper", 

26 "open", 

27 "open_files", 

28 "open_local", 

29 "registry", 

30 "caching", 

31 "Callback", 

32 "available_protocols", 

33 "available_compressions", 

34 "url_to_fs", 

35] 

36 

37 

38def process_entries(): 

39 try: 

40 from importlib.metadata import entry_points 

41 except ImportError: 

42 return 

43 if entry_points is not None: 

44 try: 

45 eps = entry_points() 

46 except TypeError: 

47 pass # importlib-metadata < 0.8 

48 else: 

49 if hasattr(eps, "select"): # Python 3.10+ / importlib_metadata >= 3.9.0 

50 specs = eps.select(group="fsspec.specs") 

51 else: 

52 specs = eps.get("fsspec.specs", []) 

53 registered_names = {} 

54 for spec in specs: 

55 err_msg = f"Unable to load filesystem from {spec}" 

56 name = spec.name 

57 if name in registered_names: 

58 continue 

59 registered_names[name] = True 

60 register_implementation( 

61 name, 

62 spec.value.replace(":", "."), 

63 errtxt=err_msg, 

64 # We take our implementations as the ones to overload with if 

65 # for some reason we encounter some, may be the same, already 

66 # registered 

67 clobber=True, 

68 ) 

69 

70 

71process_entries()