Debian Codegraph @

ansible_collections/community/general/plugins/module_utils/_gconftool2.py

raw
1 # Copyright (c) 2022, Alexei Znamensky <[email protected]>
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 # Note that this module util is **PRIVATE** to the collection. It can have breaking changes at any time.
6 # Do not use this from other collections or standalone plugins/modules!
7
8 from __future__ import annotations
9
10 import typing as t
11
12 from ansible_collections.community.general.plugins.module_utils._cmd_runner import CmdRunner, cmd_runner_fmt
13
14 if t.TYPE_CHECKING:
15 from ansible.module_utils.basic import AnsibleModule
16
17
18 _state_map = {
19 "present": "--set",
20 "absent": "--unset",
21 "get": "--get",
22 }
23
24
25 def gconftool2_runner(module: AnsibleModule, **kwargs) -> CmdRunner:
26 return CmdRunner(
27 module,
28 command="gconftool-2",
29 arg_formats=dict(
30 state=cmd_runner_fmt.as_map(_state_map),
31 key=cmd_runner_fmt.as_list(),
32 value_type=cmd_runner_fmt.as_opt_val("--type"),
33 value=cmd_runner_fmt.as_list(),
34 direct=cmd_runner_fmt.as_bool("--direct"),
35 config_source=cmd_runner_fmt.as_opt_val("--config-source"),
36 version=cmd_runner_fmt.as_fixed("--version"),
37 ),
38 **kwargs,
39 )