Config reader - vcspull._internal.config_reader¶
Warning
Be careful with these! Internal APIs are not covered by version policies. They can break or be removed between minor versions!
If you need an internal API stabilized please file an issue.
-
vcspull._internal.config_reader.config_format_from_path(path)¶
Return config format inferred from a path or symlink target.
The visible path remains the config identity, but symlinks may point at a differently named target. When the target advertises a supported config suffix, prefer that format; otherwise fall back to the visible path suffix.
- Parameters:
path (pathlib.Path) – Path to inspect.
- Returns:
"json"or"yaml"when a supported suffix is found, otherwiseNone.- Return type:
FormatLiteral | None
Examples
>>> config_format_from_path(pathlib.Path("config.yaml")) 'yaml' >>> import tempfile >>> with tempfile.TemporaryDirectory() as tmp: ... root = pathlib.Path(tmp) ... target = root / "config.json" ... _ = target.write_text("{}", encoding="utf-8") ... link = root / ".vcspull.yaml" ... link.symlink_to(target) ... config_format_from_path(link) 'json'
-
class vcspull._internal.config_reader.ConfigReader¶
Bases:
objectParse string data (YAML and JSON) into a dictionary.
>>> cfg = ConfigReader({ "session_name": "my session" }) >>> cfg.dump("yaml") 'session_name: my session\n' >>> cfg.dump("json") '{\n "session_name": "my session"\n}'
-
class vcspull._internal.config_reader._DuplicateTrackingSafeLoader¶
Bases:
SafeLoaderSafeLoader that records duplicate top-level keys.
Notes
PyYAML constructs sequence (list) items AFTER exiting parent mappings, so simple depth-counting doesn’t work for nested structures. Instead, we explicitly track the root mapping node and only consider keys as top-level if they’re direct children of that root node.
-
vcspull._internal.config_reader._duplicate_tracking_construct_mapping(loader, node, deep=False)¶
- Parameters:
loader (_DuplicateTrackingSafeLoader)
node (MappingNode)
deep (bool)
- Return type:
-
class vcspull._internal.config_reader.DuplicateAwareConfigReader¶
Bases:
ConfigReaderConfigReader that tracks duplicate top-level YAML sections.