vcspull fmt - vcspull.cli.fmt¶
Format vcspull configuration files.
- class vcspull.cli.fmt.FmtAction[source]¶
Bases:
EnumAction resolved for each repo entry during
vcspull fmt.- NORMALIZE = 'normalize'¶
- NO_CHANGE = 'no_change'¶
- SKIP_PINNED = 'skip_pinned'¶
- vcspull.cli.fmt.create_fmt_subparser(parser)[source]¶
Create
vcspull fmtargument subparser.- Return type:
- Parameters:
parser (ArgumentParser)
- vcspull.cli.fmt.normalize_repo_config(repo_data)[source]¶
Normalize repository configuration to verbose format.
- Return type:
- Parameters:
repo_data (Any) – Repository configuration (string URL or dict)
- Returns:
Normalized repository configuration with ‘repo’ key
- Return type:
Examples
String entries are wrapped:
>>> from vcspull.cli.fmt import normalize_repo_config >>> normalize_repo_config("git+https://example.com/r.git") {'repo': 'git+https://example.com/r.git'}
Dict with
urlkey is normalized torepo:>>> normalize_repo_config({"url": "git+https://example.com/r.git"}) {'repo': 'git+https://example.com/r.git'}
Dict already using
repokey passes through unchanged:>>> normalize_repo_config({"repo": "git+https://example.com/r.git"}) {'repo': 'git+https://example.com/r.git'}
When both
urlandrepokeys are present, both are preserved (deduplication is left to the caller):>>> normalize_repo_config({"url": "git+https://example.com/u.git", "repo": "git+https://example.com/r.git"}) {'url': 'git+https://example.com/u.git', 'repo': 'git+https://example.com/r.git'}
- vcspull.cli.fmt._classify_fmt_action(repo_data)[source]¶
Classify the fmt action for a single repository entry.
Returns the action and the (possibly normalized) data so that callers do not need to call
normalize_repo_config()a second time.- Return type:
- Parameters:
repo_data (Any) – Repository configuration value (string, dict, or other).
- Returns:
The resolved action and the resulting repo data. For
NORMALIZEthe second element is the normalized dict; forNO_CHANGEandSKIP_PINNEDit is the original repo_data.- Return type:
Examples
String entries need normalization:
>>> _classify_fmt_action("git+ssh://x") (<FmtAction.NORMALIZE: 'normalize'>, {'repo': 'git+ssh://x'})
Dict with
urlkey needs normalization:>>> _classify_fmt_action({"url": "git+ssh://x"}) (<FmtAction.NORMALIZE: 'normalize'>, {'repo': 'git+ssh://x'})
Already normalized dict:
>>> _classify_fmt_action({"repo": "git+ssh://x"}) (<FmtAction.NO_CHANGE: 'no_change'>, {'repo': 'git+ssh://x'})
Pinned entry is preserved verbatim:
>>> pinned = {"repo": "git+ssh://x", "options": {"pin": True}} >>> action, data = _classify_fmt_action(pinned) >>> action <FmtAction.SKIP_PINNED: 'skip_pinned'> >>> data == pinned True >>> entry = {"repo": "git+ssh://x", "options": {"pin": {"fmt": True}}} >>> _classify_fmt_action(entry)[0] <FmtAction.SKIP_PINNED: 'skip_pinned'>
Pinned for import only — fmt still normalizes:
>>> entry = {"url": "git+ssh://x", "options": {"pin": {"import": True}}} >>> action, data = _classify_fmt_action(entry) >>> action <FmtAction.NORMALIZE: 'normalize'> >>> data["repo"] 'git+ssh://x'
- vcspull.cli.fmt.format_single_config(config_file_path, write, *, merge_roots)[source]¶
Format a single vcspull configuration file.
- Return type:
- Parameters:
config_file_path (pathlib.Path) – Path to config file
write (bool) – Whether to write changes back to file
merge_roots (bool) – Merge duplicate workspace roots when True (default behavior)
- Returns:
True if formatting was successful, False otherwise
- Return type: