azpaddypy 0.5.4__py3-none-any.whl → 0.5.6__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.
- azpaddypy/mgmt/local_env_manager.py +21 -38
- {azpaddypy-0.5.4.dist-info → azpaddypy-0.5.6.dist-info}/METADATA +1 -1
- {azpaddypy-0.5.4.dist-info → azpaddypy-0.5.6.dist-info}/RECORD +6 -6
- {azpaddypy-0.5.4.dist-info → azpaddypy-0.5.6.dist-info}/WHEEL +0 -0
- {azpaddypy-0.5.4.dist-info → azpaddypy-0.5.6.dist-info}/licenses/LICENSE +0 -0
- {azpaddypy-0.5.4.dist-info → azpaddypy-0.5.6.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,6 @@ import os
|
|
2
2
|
import json
|
3
3
|
import pathlib
|
4
4
|
from typing import Dict, Optional, Union
|
5
|
-
from .logging import AzureLogger
|
6
5
|
|
7
6
|
|
8
7
|
class LocalDevelopmentSettings:
|
@@ -14,37 +13,23 @@ class LocalDevelopmentSettings:
|
|
14
13
|
with deployed Azure environments.
|
15
14
|
|
16
15
|
It supports overriding existing environment variables and provides clear
|
17
|
-
|
18
|
-
|
19
|
-
Attributes:
|
20
|
-
logger: An instance of AzureLogger for structured logging.
|
16
|
+
output for loaded settings.
|
21
17
|
"""
|
22
18
|
|
23
19
|
def __init__(
|
24
20
|
self,
|
25
21
|
service_name: str = "local_dev_settings",
|
26
22
|
service_version: str = "1.0.0",
|
27
|
-
logger: Optional[AzureLogger] = None,
|
28
|
-
connection_string: Optional[str] = None,
|
29
23
|
):
|
30
24
|
"""Initializes the LocalDevelopmentSettings manager.
|
31
25
|
|
32
26
|
Args:
|
33
27
|
service_name: The name of the service using the settings manager.
|
34
28
|
service_version: The version of the service.
|
35
|
-
logger: An optional existing AzureLogger instance.
|
36
|
-
connection_string: Application Insights connection string for a new logger.
|
37
29
|
"""
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
self.logger = AzureLogger(
|
42
|
-
service_name=service_name,
|
43
|
-
service_version=service_version,
|
44
|
-
connection_string=connection_string,
|
45
|
-
enable_console_logging=True,
|
46
|
-
)
|
47
|
-
self.logger.info("LocalDevelopmentSettings initialized.")
|
30
|
+
self.service_name = service_name
|
31
|
+
self.service_version = service_version
|
32
|
+
print(f"[{self.service_name}] LocalDevelopmentSettings initialized.")
|
48
33
|
|
49
34
|
def load_from_dotenv(
|
50
35
|
self,
|
@@ -62,7 +47,7 @@ class LocalDevelopmentSettings:
|
|
62
47
|
"""
|
63
48
|
dotenv_path = pathlib.Path(dotenv_path)
|
64
49
|
if not dotenv_path.is_file():
|
65
|
-
|
50
|
+
print(f"[{self.service_name}] WARNING: .env file not found at {dotenv_path}. Skipping.")
|
66
51
|
return False
|
67
52
|
|
68
53
|
try:
|
@@ -81,14 +66,14 @@ class LocalDevelopmentSettings:
|
|
81
66
|
|
82
67
|
if key not in os.environ or override:
|
83
68
|
os.environ[key] = value
|
84
|
-
|
69
|
+
print(f"[{self.service_name}] DEBUG: Loaded from .env: {key}={value[:8]}...")
|
85
70
|
else:
|
86
|
-
|
71
|
+
print(f"[{self.service_name}] DEBUG: Skipping from .env (exists): {key}")
|
87
72
|
|
88
|
-
|
73
|
+
print(f"[{self.service_name}] Successfully loaded settings from {dotenv_path}")
|
89
74
|
return True
|
90
75
|
except Exception as e:
|
91
|
-
|
76
|
+
print(f"[{self.service_name}] ERROR: Error reading .env file at {dotenv_path}: {e}")
|
92
77
|
return False
|
93
78
|
|
94
79
|
def load_from_json(
|
@@ -110,7 +95,7 @@ class LocalDevelopmentSettings:
|
|
110
95
|
"""
|
111
96
|
json_path = pathlib.Path(json_path)
|
112
97
|
if not json_path.is_file():
|
113
|
-
|
98
|
+
print(f"[{self.service_name}] WARNING: JSON settings file not found at {json_path}. Skipping.")
|
114
99
|
return False
|
115
100
|
|
116
101
|
try:
|
@@ -121,19 +106,19 @@ class LocalDevelopmentSettings:
|
|
121
106
|
for key, value in settings["Values"].items():
|
122
107
|
if key not in os.environ or override:
|
123
108
|
os.environ[key] = str(value)
|
124
|
-
|
109
|
+
print(f"[{self.service_name}] DEBUG: Loaded from JSON: {key}={str(value)[:8]}...")
|
125
110
|
else:
|
126
|
-
|
127
|
-
|
111
|
+
print(f"[{self.service_name}] DEBUG: Skipping from JSON (exists): {key}")
|
112
|
+
print(f"[{self.service_name}] Successfully loaded settings from {json_path}")
|
128
113
|
return True
|
129
114
|
else:
|
130
|
-
|
115
|
+
print(f"[{self.service_name}] WARNING: No 'Values' dictionary found in {json_path}. Skipping.")
|
131
116
|
return False
|
132
117
|
except json.JSONDecodeError:
|
133
|
-
|
118
|
+
print(f"[{self.service_name}] ERROR: Error decoding JSON from {json_path}.")
|
134
119
|
return False
|
135
120
|
except Exception as e:
|
136
|
-
|
121
|
+
print(f"[{self.service_name}] ERROR: Error reading JSON file at {json_path}: {e}")
|
137
122
|
return False
|
138
123
|
|
139
124
|
def apply_settings(
|
@@ -150,21 +135,20 @@ class LocalDevelopmentSettings:
|
|
150
135
|
for key, value in settings.items():
|
151
136
|
if key not in os.environ or override:
|
152
137
|
os.environ[key] = str(value)
|
153
|
-
|
138
|
+
print(f"[{self.service_name}] DEBUG: Applied setting: {key}={str(value)[:8]}...")
|
154
139
|
else:
|
155
|
-
|
156
|
-
|
140
|
+
print(f"[{self.service_name}] DEBUG: Skipping setting (exists): {key}")
|
141
|
+
print(f"[{self.service_name}] Applied {len(settings)} settings to environment.")
|
157
142
|
|
158
143
|
def print_settings(self):
|
159
144
|
"""Prints the current settings as a dictionary."""
|
160
145
|
for key, value in os.environ.items():
|
161
|
-
|
146
|
+
print(f"[{self.service_name}] DEBUG: Setting: {key}={value[:8]}...")
|
162
147
|
|
163
148
|
|
164
149
|
def create_local_env_manager(
|
165
150
|
file_path: str = ".env",
|
166
151
|
settings: Optional[Dict[str, str]] = None,
|
167
|
-
logger: Optional[AzureLogger] = None,
|
168
152
|
override_json: bool = True,
|
169
153
|
override_dotenv: bool = True,
|
170
154
|
override_settings: bool = True
|
@@ -179,12 +163,11 @@ def create_local_env_manager(
|
|
179
163
|
file_path: Base path for `.env` or `local.settings.json`. The function
|
180
164
|
will look for both.
|
181
165
|
settings: A dictionary of settings to apply.
|
182
|
-
logger: An optional AzureLogger instance.
|
183
166
|
override_json: Whether settings from JSON should override existing env vars.
|
184
167
|
override_dotenv: Whether settings from .env should override existing env vars.
|
185
168
|
override_settings: Whether settings from the dictionary should override.
|
186
169
|
"""
|
187
|
-
manager = LocalDevelopmentSettings(
|
170
|
+
manager = LocalDevelopmentSettings()
|
188
171
|
loadded_from_json = False
|
189
172
|
loadded_from_dotenv = False
|
190
173
|
# Try loading local.settings.json
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: azpaddypy
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.6
|
4
4
|
Summary: Comprehensive Python logger for Azure, integrating OpenTelemetry for advanced, structured, and distributed tracing.
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
6
6
|
Classifier: Operating System :: OS Independent
|
@@ -1,12 +1,12 @@
|
|
1
1
|
azpaddypy/__init__.py,sha256=hrWNAh4OHZOvm3Pbhq5eUjO-pSRYn0h0W0J87tc-lNI,45
|
2
2
|
azpaddypy/mgmt/__init__.py,sha256=waW9EAnTFDh2530ieQX1Z0r0Z-ZKHRwabVDfapjfN58,441
|
3
3
|
azpaddypy/mgmt/identity.py,sha256=mA_krQslMsK_sDob-z-QA0B9khK_JUO2way7xwPopR8,12001
|
4
|
-
azpaddypy/mgmt/local_env_manager.py,sha256=
|
4
|
+
azpaddypy/mgmt/local_env_manager.py,sha256=WHXJXHQFGwkgr96YkEtqpgFUxmCjBa5pArbNxZUSKQk,7762
|
5
5
|
azpaddypy/mgmt/logging.py,sha256=3ZLSKwpX7Tprthrkm3uN4ph2n2CxiGYUNri7jBJuXEY,36514
|
6
6
|
azpaddypy/resources/__init__.py,sha256=Bvt3VK4RqwoxYpoh6EbLXIR18RuFPKaLP6zLL-icyFk,314
|
7
7
|
azpaddypy/resources/keyvault.py,sha256=4J08vLqoLFd1_UUDBji2oG2fatZaPkgnRyT_Z6wHAOc,20312
|
8
|
-
azpaddypy-0.5.
|
9
|
-
azpaddypy-0.5.
|
10
|
-
azpaddypy-0.5.
|
11
|
-
azpaddypy-0.5.
|
12
|
-
azpaddypy-0.5.
|
8
|
+
azpaddypy-0.5.6.dist-info/licenses/LICENSE,sha256=hQ6t0g2QaewGCQICHqTckBFbMVakGmoyTAzDpmEYV4c,1089
|
9
|
+
azpaddypy-0.5.6.dist-info/METADATA,sha256=1x7g8M_qFPHUAHdTc61UTnbb-Jix4h0ranreTduPFfs,665
|
10
|
+
azpaddypy-0.5.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
azpaddypy-0.5.6.dist-info/top_level.txt,sha256=hsDuboDhT61320ML8X479ezSTwT3rrlDWz1_Z45B2cs,10
|
12
|
+
azpaddypy-0.5.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|