f
This commit is contained in:
@@ -187,6 +187,21 @@ def _apply_conf_block(
|
||||
tool[tool_name] = dict(block)
|
||||
return
|
||||
|
||||
if kind_l == "networking":
|
||||
net_name = str(subtype).strip().lower()
|
||||
if not net_name:
|
||||
return
|
||||
net = config.setdefault("networking", {})
|
||||
if not isinstance(net, dict):
|
||||
config["networking"] = {}
|
||||
net = config["networking"]
|
||||
existing = net.get(net_name)
|
||||
if isinstance(existing, dict):
|
||||
_merge_dict_inplace(existing, block)
|
||||
else:
|
||||
net[net_name] = dict(block)
|
||||
return
|
||||
|
||||
|
||||
def parse_conf_text(text: str, *, base: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||
"""Parse a lightweight .conf format into the app's config dict.
|
||||
@@ -284,7 +299,7 @@ def _serialize_conf(config: Dict[str, Any]) -> str:
|
||||
|
||||
# Top-level scalars first
|
||||
for key in sorted(config.keys()):
|
||||
if key in {"store", "provider", "tool"}:
|
||||
if key in {"store", "provider", "tool", "networking"}:
|
||||
continue
|
||||
value = config.get(key)
|
||||
if isinstance(value, dict):
|
||||
@@ -351,6 +366,24 @@ def _serialize_conf(config: Dict[str, Any]) -> str:
|
||||
seen_keys.add(k_upper)
|
||||
lines.append(f"{k}={_format_conf_value(block.get(k))}")
|
||||
|
||||
# Networking blocks
|
||||
networking = config.get("networking")
|
||||
if isinstance(networking, dict):
|
||||
for name in sorted(networking.keys()):
|
||||
block = networking.get(name)
|
||||
if not isinstance(block, dict):
|
||||
continue
|
||||
lines.append("")
|
||||
lines.append(f"[networking={name}]")
|
||||
|
||||
seen_keys = set()
|
||||
for k in sorted(block.keys()):
|
||||
k_upper = k.upper()
|
||||
if k_upper in seen_keys:
|
||||
continue
|
||||
seen_keys.add(k_upper)
|
||||
lines.append(f"{k}={_format_conf_value(block.get(k))}")
|
||||
|
||||
return "\n".join(lines).rstrip() + "\n"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user