MCPcopy Index your code
hub / github.com/pyinvoke/invoke / update_config

Method update_config

invoke/program.py:302–353  ·  view source on GitHub ↗

Update the previously instantiated `.Config` with parsed data. For example, this is how ``--echo`` is able to override the default config value for ``run.echo``. :param bool merge: Whether to merge at the end, or defer. Primarily useful for

(self, merge: bool = True)

Source from the content-addressed store, hash-verified

300 self.config = self.config_class()
301
302 def update_config(self, merge: bool = True) -> None:
303 """
304 Update the previously instantiated `.Config` with parsed data.
305
306 For example, this is how ``--echo`` is able to override the default
307 config value for ``run.echo``.
308
309 :param bool merge:
310 Whether to merge at the end, or defer. Primarily useful for
311 subclassers. Default: ``True``.
312
313 .. versionadded:: 1.0
314 """
315 # Now that we have parse results handy, we can grab the remaining
316 # config bits:
317 # - runtime config, as it is dependent on the runtime flag/env var
318 # - the overrides config level, as it is composed of runtime flag data
319 # NOTE: only fill in values that would alter behavior, otherwise we
320 # want the defaults to come through.
321 run = {}
322 if self.args["warn-only"].value:
323 run["warn"] = True
324 if self.args.pty.value:
325 run["pty"] = True
326 if self.args.hide.value:
327 run["hide"] = self.args.hide.value
328 if self.args.echo.value:
329 run["echo"] = True
330 if self.args.dry.value:
331 run["dry"] = True
332 tasks = {}
333 if "no-dedupe" in self.args and self.args["no-dedupe"].value:
334 tasks["dedupe"] = False
335 timeouts = {}
336 command = self.args["command-timeout"].value
337 if command:
338 timeouts["command"] = command
339 # Handle "fill in config values at start of runtime", which for now is
340 # just sudo password
341 sudo = {}
342 if self.args["prompt-for-sudo-password"].value:
343 prompt = "Desired 'sudo.password' config value: "
344 sudo["password"] = getpass.getpass(prompt)
345 overrides = dict(run=run, tasks=tasks, sudo=sudo, timeouts=timeouts)
346 self.config.load_overrides(overrides, merge=False)
347 runtime_path = self.args.config.value
348 if runtime_path is None:
349 runtime_path = os.environ.get("INVOKE_RUNTIME_CONFIG", None)
350 self.config.set_runtime_path(runtime_path)
351 self.config.load_runtime(merge=False)
352 if merge:
353 self.config.merge()
354
355 def run(self, argv: Optional[List[str]] = None, exit: bool = True) -> None:
356 """

Callers 1

runMethod · 0.95

Calls 5

load_overridesMethod · 0.80
getMethod · 0.80
set_runtime_pathMethod · 0.80
load_runtimeMethod · 0.80
mergeMethod · 0.80

Tested by

no test coverage detected