onedatarestfsspec 25.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ """OnedataRESTFSSpec: fsspec filesystem implementation for Onedata."""
2
+
3
+ from .core import OnedataFileSystem
4
+
5
+ __version__ = "25.0.0"
6
+ __all__ = ["OnedataFileSystem"]
@@ -0,0 +1,88 @@
1
+ """Configuration handling for OnedataRESTFSSpec."""
2
+
3
+ import os
4
+ from typing import Any, Dict, List, Union
5
+
6
+
7
+ def get_onedata_config_from_env() -> (
8
+ Dict[str, Union[str, List[str], bool, float, None]]
9
+ ):
10
+ """Get Onedata configuration from environment variables.
11
+
12
+ Returns
13
+ -------
14
+ dict
15
+ Configuration from environment variables
16
+ """
17
+ onezone_host = os.environ.get("ONEDATA_ONEZONE_HOST")
18
+ token = os.environ.get("ONEDATA_TOKEN")
19
+
20
+ timeout_str = os.environ.get("ONEDATA_TIMEOUT", "30")
21
+ timeout = 30.0 if not timeout_str or timeout_str == "" else float(timeout_str)
22
+
23
+ providers_str = os.environ.get("ONEDATA_PREFERRED_PROVIDERS")
24
+ providers = (
25
+ providers_str.split(",") if providers_str and providers_str.strip() else None
26
+ )
27
+
28
+ verify_ssl_str = os.environ.get("ONEDATA_VERIFY_SSL", "true")
29
+ verify_ssl = (
30
+ verify_ssl_str.lower() in ("true", "1")
31
+ if verify_ssl_str and verify_ssl_str.strip()
32
+ else True
33
+ )
34
+
35
+ metrics_enabled_str = os.environ.get("ONEDATA_METRICS_ENABLED", "")
36
+ metrics_enabled = metrics_enabled_str.lower() in ("true", "1")
37
+
38
+ return {
39
+ "onezone_host": onezone_host if onezone_host and onezone_host.strip() else None,
40
+ "token": token if token and token.strip() else None,
41
+ "preferred_providers": providers,
42
+ "verify_ssl": verify_ssl,
43
+ "timeout": timeout,
44
+ "metrics_enabled": metrics_enabled,
45
+ }
46
+
47
+
48
+ def merge_config(
49
+ url_config: Dict[str, Any],
50
+ env_config: Dict[str, Any],
51
+ explicit_config: Dict[str, Any],
52
+ ) -> Dict[str, Any]:
53
+ """Merge configuration from different sources.
54
+
55
+ Priority: explicit_config > url_config > env_config
56
+
57
+ Parameters
58
+ ----------
59
+ url_config : dict
60
+ Configuration from URL
61
+ env_config : dict
62
+ Configuration from environment
63
+ explicit_config : dict
64
+ Explicitly provided configuration
65
+
66
+ Returns
67
+ -------
68
+ dict
69
+ Merged configuration
70
+ """
71
+ config = {}
72
+
73
+ # Start with environment config
74
+ for key, value in env_config.items():
75
+ if value is not None:
76
+ config[key] = value
77
+
78
+ # Override with URL config
79
+ for key, value in url_config.items():
80
+ if value is not None:
81
+ config[key] = value
82
+
83
+ # Override with explicit config
84
+ for key, value in explicit_config.items():
85
+ if value is not None:
86
+ config[key] = value
87
+
88
+ return config