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

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

29 statements  

1from importlib.metadata import entry_points 

2 

3from . import caching 

4from ._version import __version__ # noqa: F401 

5from .callbacks import Callback 

6from .compression import available_compressions 

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

8from .exceptions import FSTimeoutError 

9from .mapping import FSMap, get_mapper 

10from .registry import ( 

11 available_protocols, 

12 filesystem, 

13 get_filesystem_class, 

14 register_implementation, 

15 registry, 

16) 

17from .spec import AbstractFileSystem 

18 

19__all__ = [ 

20 "AbstractFileSystem", 

21 "FSTimeoutError", 

22 "FSMap", 

23 "filesystem", 

24 "register_implementation", 

25 "get_filesystem_class", 

26 "get_fs_token_paths", 

27 "get_mapper", 

28 "open", 

29 "open_files", 

30 "open_local", 

31 "registry", 

32 "caching", 

33 "Callback", 

34 "available_protocols", 

35 "available_compressions", 

36 "url_to_fs", 

37] 

38 

39 

40def process_entries(): 

41 if entry_points is not None: 

42 try: 

43 eps = entry_points() 

44 except TypeError: 

45 pass # importlib-metadata < 0.8 

46 else: 

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

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

49 else: 

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

51 registered_names = {} 

52 for spec in specs: 

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

54 name = spec.name 

55 if name in registered_names: 

56 continue 

57 registered_names[name] = True 

58 register_implementation( 

59 name, 

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

61 errtxt=err_msg, 

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

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

64 # registered 

65 clobber=True, 

66 ) 

67 

68 

69process_entries()