xenfra 0.3.5__py3-none-any.whl → 0.3.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.
xenfra/utils/config.py CHANGED
@@ -280,6 +280,68 @@ def apply_patch(patch: dict, target_file: str = None, create_backup_file: bool =
280
280
  # Replace entire file
281
281
  with open(file_to_patch, "w") as f:
282
282
  f.write(str(value))
283
+
284
+ # For TOML files (pyproject.toml)
285
+ elif file_to_patch.endswith(".toml"):
286
+ import toml
287
+
288
+ with open(file_to_patch, "r") as f:
289
+ config_data = toml.load(f)
290
+
291
+ operation = patch.get("operation")
292
+ path = patch.get("path", "").strip("/")
293
+ value = patch.get("value")
294
+
295
+ if operation == "add":
296
+ # Special case for pyproject.toml dependencies
297
+ is_pyproject = os.path.basename(file_to_patch) == "pyproject.toml"
298
+ if is_pyproject and (not path or path == "project/dependencies"):
299
+ # Ensure project and dependencies exist
300
+ if "project" not in config_data:
301
+ config_data["project"] = {}
302
+ if "dependencies" not in config_data["project"]:
303
+ config_data["project"]["dependencies"] = []
304
+
305
+ # Add value if not already present
306
+ if value not in config_data["project"]["dependencies"]:
307
+ config_data["project"]["dependencies"].append(value)
308
+ elif path:
309
+ path_parts = path.split("/")
310
+ current = config_data
311
+ for part in path_parts[:-1]:
312
+ if part not in current:
313
+ current[part] = {}
314
+ current = current[part]
315
+
316
+ # If target is a list (like dependencies), append
317
+ target_key = path_parts[-1]
318
+ if target_key in current and isinstance(current[target_key], list):
319
+ if value not in current[target_key]:
320
+ current[target_key].append(value)
321
+ else:
322
+ current[target_key] = value
323
+ else:
324
+ # Root level add
325
+ if isinstance(value, dict):
326
+ config_data.update(value)
327
+ else:
328
+ # Ignore root-level non-dict adds for structured files
329
+ # to prevent overwriting the entire config with a string
330
+ pass
331
+
332
+ elif operation == "replace":
333
+ if path:
334
+ path_parts = path.split("/")
335
+ current = config_data
336
+ for part in path_parts[:-1]:
337
+ current = current[part]
338
+ current[path_parts[-1]] = value
339
+ else:
340
+ config_data = value
341
+
342
+ # Write back
343
+ with open(file_to_patch, "w") as f:
344
+ toml.dump(config_data, f)
283
345
  else:
284
346
  # Design decision: Only support auto-patching for common dependency files
285
347
  # Other file types should be manually edited to avoid data loss
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: xenfra
3
- Version: 0.3.5
3
+ Version: 0.3.6
4
4
  Summary: A 'Zen Mode' infrastructure engine for Python developers.
5
5
  Author: xenfra-cloud
6
6
  Author-email: xenfra-cloud <xenfracloud@gmail.com>
@@ -24,6 +24,7 @@ Requires-Dist: keyring>=25.7.0
24
24
  Requires-Dist: keyrings-alt>=5.0.2
25
25
  Requires-Dist: tenacity>=8.2.3
26
26
  Requires-Dist: cryptography>=43.0.0
27
+ Requires-Dist: toml>=0.10.2
27
28
  Requires-Dist: pytest>=8.0.0 ; extra == 'test'
28
29
  Requires-Dist: pytest-mock>=3.12.0 ; extra == 'test'
29
30
  Requires-Python: >=3.13
@@ -10,11 +10,11 @@ xenfra/main.py,sha256=2EPPuIdxjhW-I-e-Mc0i2ayeLaSJdmzddNThkXq7B7c,2033
10
10
  xenfra/utils/__init__.py,sha256=4ZRYkrb--vzoXjBHG8zRxz2jCXNGtAoKNtkyu2WRI2A,45
11
11
  xenfra/utils/auth.py,sha256=9JbFnv0-rdlJF-4hKD2uWd9h9ehqC1iIHee1O5e-3RM,13769
12
12
  xenfra/utils/codebase.py,sha256=GMrqhOJWX8q5ZXSLI9P3hJZBpufXMQA3Z4fKh2XSTNo,5949
13
- xenfra/utils/config.py,sha256=F2zedd3JXP7TBdul0u8b4NVx-C1N6Hq4sH5szyWim6M,11947
13
+ xenfra/utils/config.py,sha256=UjTRIINSg6vPdtC3akJGxnisX621uoh8_JkhhfHl2RE,14519
14
14
  xenfra/utils/errors.py,sha256=6G91YzzDDNkKHANTgfAMiOiMElEyi57wo6-FzRa4VuQ,4211
15
15
  xenfra/utils/security.py,sha256=EA8CIPLt8Y-QP5uZ7c5NuC6ZLRV1aZS8NapS9ix_vok,11479
16
16
  xenfra/utils/validation.py,sha256=cvuL_AEFJ2oCoP0abCqoOIABOwz79Gkf-jh_dcFIQlM,6912
17
- xenfra-0.3.5.dist-info/WHEEL,sha256=KSLUh82mDPEPk0Bx0ScXlWL64bc8KmzIPNcpQZFV-6E,79
18
- xenfra-0.3.5.dist-info/entry_points.txt,sha256=a_2cGhYK__X6eW05Ba8uB6RIM_61c2sHtXsPY8N0mic,45
19
- xenfra-0.3.5.dist-info/METADATA,sha256=OrFNS_krWEq8-BglAdLn5A1Lpel4bxWcpDcqDcsmrRk,3870
20
- xenfra-0.3.5.dist-info/RECORD,,
17
+ xenfra-0.3.6.dist-info/WHEEL,sha256=KSLUh82mDPEPk0Bx0ScXlWL64bc8KmzIPNcpQZFV-6E,79
18
+ xenfra-0.3.6.dist-info/entry_points.txt,sha256=a_2cGhYK__X6eW05Ba8uB6RIM_61c2sHtXsPY8N0mic,45
19
+ xenfra-0.3.6.dist-info/METADATA,sha256=t9JZDfEXmmUIj8_BYUlhNVTd_bymZSDDdqzVaxgbMl8,3898
20
+ xenfra-0.3.6.dist-info/RECORD,,
File without changes