machineconfig 3.86__py3-none-any.whl → 3.88__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.

Potentially problematic release.


This version of machineconfig might be problematic. Click here for more details.

@@ -4,7 +4,7 @@ Type definitions for the standardized layout configuration schema.
4
4
  This module defines the data structures that match the layout.json schema.
5
5
  """
6
6
 
7
- from typing import TypedDict, List
7
+ from typing import TypedDict, List, Literal
8
8
 
9
9
 
10
10
  class TabConfig(TypedDict):
@@ -27,3 +27,35 @@ class LayoutsFile(TypedDict):
27
27
 
28
28
  version: str
29
29
  layouts: List[LayoutConfig]
30
+
31
+
32
+ def serialize_layouts_to_file(layouts: list[LayoutConfig], version: Literal["0.1"], path: str):
33
+ """Serialize a LayoutConfig to a JSON string."""
34
+ import json
35
+ layout_file: LayoutsFile = {
36
+ "version": version,
37
+ "layouts": layouts,
38
+ }
39
+ # add "$schema" key pointing to https://bit.ly/cfglayout
40
+ layout_dict = {
41
+ "$schema": "https://bit.ly/cfglayout",
42
+ **layout_file
43
+ }
44
+ json_string = json.dumps(layout_dict, indent=4)
45
+ from pathlib import Path
46
+ p = Path(path)
47
+ p.parent.mkdir(parents=True, exist_ok=True)
48
+ if not p.exists():
49
+ p.write_text(json_string, encoding="utf-8")
50
+ return None
51
+ existing_content_layout: LayoutsFile = json.loads(p.read_text(encoding="utf-8"))
52
+ # policy: if layout with same name exists, replace it. we don't lool at tabConfig differences.
53
+ for a_new_layout in layouts:
54
+ for i, existing_layout in enumerate(existing_content_layout["layouts"]):
55
+ if existing_layout["layoutName"] == a_new_layout["layoutName"]:
56
+ existing_content_layout["layouts"][i] = a_new_layout
57
+ break
58
+ else:
59
+ existing_content_layout["layouts"].append(a_new_layout)
60
+ p.write_text(json.dumps(existing_content_layout, indent=4), encoding="utf-8")
61
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machineconfig
3
- Version: 3.86
3
+ Version: 3.88
4
4
  Summary: Dotfiles management package
5
5
  Author-email: Alex Al-Saffar <programmer@usa.com>
6
6
  License: Apache 2.0
@@ -420,10 +420,10 @@ machineconfig/utils/installer_utils/installer_abc.py,sha256=iB1_PZLQGouCdEA8bixd
420
420
  machineconfig/utils/installer_utils/installer_class.py,sha256=P3ZKr92b0ofbQCJUyK3eU3FVgK1ZMRw36WH-rbR5pAw,20430
421
421
  machineconfig/utils/schemas/fire_agents/fire_agents_input.py,sha256=CCs5ebomW1acKWZRpv9dyDzM-W6pwvVplikcutE2D8I,2339
422
422
  machineconfig/utils/schemas/installer/installer_types.py,sha256=iAzcALc9z_FAQE9iuGHfX6Z0B1_n3Gt6eC0d6heYik0,599
423
- machineconfig/utils/schemas/layouts/layout_types.py,sha256=OmiOX9xtakPz4l6IobWnpFHpbn95fitEE9q0YL1WxjQ,617
423
+ machineconfig/utils/schemas/layouts/layout_types.py,sha256=M1ZFCz_kjRZPhxM19rIYUDR5lDDpwa09odR_ihtIFq0,1932
424
424
  machineconfig/utils/schemas/repos/repos_types.py,sha256=ECVr-3IVIo8yjmYmVXX2mnDDN1SLSwvQIhx4KDDQHBQ,405
425
- machineconfig-3.86.dist-info/METADATA,sha256=-bdJW9-zCFRkinXlSz0koiGWe1XOoRl-399jJhh-IIY,6998
426
- machineconfig-3.86.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
427
- machineconfig-3.86.dist-info/entry_points.txt,sha256=rSx_9gXd2stziS1OkNy__jF647hrRxRiF6zolLUELc4,1153
428
- machineconfig-3.86.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
429
- machineconfig-3.86.dist-info/RECORD,,
425
+ machineconfig-3.88.dist-info/METADATA,sha256=9lxn7WjqHpXrQZf633ZzqR190I1ZPVSqK0arz77rq_E,6998
426
+ machineconfig-3.88.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
427
+ machineconfig-3.88.dist-info/entry_points.txt,sha256=rSx_9gXd2stziS1OkNy__jF647hrRxRiF6zolLUELc4,1153
428
+ machineconfig-3.88.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
429
+ machineconfig-3.88.dist-info/RECORD,,