Config and trust command internals

vcspull.cli.config implements vcspull config and vcspull trust — reporting active configuration scopes and managing the trusted project directory state file.

Configuration scope introspection and project trust for vcspull.

vcspull.cli.config.create_config_subparser(parser, scope_parent)
function[source]
function[source]
vcspull.cli.config.create_config_subparser(parser, scope_parent)

Create vcspull config argument subparser.

Parameters:
Return type:

None

vcspull.cli.config.create_trust_subparser(parser)
function[source]
function[source]
vcspull.cli.config.create_trust_subparser(parser)

Create vcspull trust argument subparser.

Parameters:

parser (ArgumentParser)

Return type:

None

vcspull.cli.config._plural(count, singular, plural=None)
function[source]
function[source]
vcspull.cli.config._plural(count, singular, plural=None)

Return count with a correctly inflected noun.

Examples

>>> _plural(1, "repo")
'1 repo'
>>> _plural(0, "repo")
'0 repos'
>>> _plural(2, "repository", "repositories")
'2 repositories'
Parameters:
Return type:

str

vcspull.cli.config._note(declared, effective, *, untrusted)
function[source]
function[source]
vcspull.cli.config._note(declared, effective, *, untrusted)

Return the parenthetical explaining why a file’s count is not its whole.

Examples

>>> _note(2, 2, untrusted=False)
''
>>> _note(2, 1, untrusted=False)
' (1 overridden)'
>>> _note(2, 0, untrusted=True)
' (untrusted)'
Parameters:
Return type:

str

vcspull.cli.config._declared_repos(path, cwd)
function[source]
function[source]
vcspull.cli.config._declared_repos(path, cwd)

Return the destination of every repository a single file declares.

Parameters:
Return type:

list[Path]

class vcspull.cli.config._ScopeRow
class vcspull.cli.config._ScopeRow

Bases: NamedTuple

One line of vcspull config ls.

vcspull.cli.config.config_ls(*, include_project=True, trust_project=False, cwd=None)
function[source]
function[source]
vcspull.cli.config.config_ls(*, include_project=True, trust_project=False, cwd=None)

Print the configuration scopes in effect, weakest first.

Each row is a file, its scope, and how many repositories it declares. A file whose entries are overridden by a nearer one says so, and a project file awaiting trust is listed as untrusted rather than silently dropped — this is the command you reach for when vcspull list refuses to load something.

Parameters:
  • include_project (bool) – Set False to show the stack as --no-project resolves it.

  • trust_project (bool) – Treat escaping project configs as trusted, as --trust-project does.

  • cwd (pathlib.Path, optional) – Working directory. Defaults to pathlib.Path.cwd().

Return type:

None

vcspull.cli.config.trust_command(directory, *, untrust=False, show=False, state_file=None)
function[source]
function[source]
vcspull.cli.config.trust_command(directory, *, untrust=False, show=False, state_file=None)

Record, remove, or print trusted project directories.

Parameters:
Return type:

None

Examples

>>> state = tmp_path / "trusted"
>>> trust_command(None, show=True, state_file=state)
no trusted project directories
>>> api = tmp_path / "api"
>>> api.mkdir()
>>> trust_command(str(api), state_file=state)
trusted ...api
>>> scopes.read_trusted(state) == frozenset({api})
True
>>> trust_command(str(api), untrust=True, state_file=state)
untrusted ...api
>>> scopes.read_trusted(state)
frozenset()