Debian Codegraph @

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

raw
1 # Copyright (c) 2023, 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 def locale_runner(module: AnsibleModule) -> CmdRunner:
19 runner = CmdRunner(
20 module,
21 command=["locale", "-a"],
22 check_rc=True,
23 )
24 return runner
25
26
27 def locale_gen_runner(module: AnsibleModule) -> CmdRunner:
28 runner = CmdRunner(
29 module,
30 command="locale-gen",
31 arg_formats=dict(
32 name=cmd_runner_fmt.as_list(),
33 purge=cmd_runner_fmt.as_fixed("--purge"),
34 ),
35 check_rc=True,
36 )
37 return runner