mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
[PR #10311/5462b1cf backport][stable-11] xfconf: small refactor (#10312)
xfconf: small refactor (#10311)
* xfconf: small refactor
* add changelog frag
* Update changelogs/fragments/10311-xfconf-refactor.yml
---------
(cherry picked from commit 5462b1cff8)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
2
changelogs/fragments/10311-xfconf-refactor.yml
Normal file
2
changelogs/fragments/10311-xfconf-refactor.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- xfconf - minor adjustments the the code (https://github.com/ansible-collections/community.general/pull/10311).
|
||||||
@@ -178,7 +178,7 @@ class XFConfProperty(StateModuleHelper):
|
|||||||
output_params = ('property', 'channel', 'value')
|
output_params = ('property', 'channel', 'value')
|
||||||
module = dict(
|
module = dict(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
state=dict(type='str', choices=("present", "absent"), default="present"),
|
state=dict(type='str', choices=('present', 'absent'), default='present'),
|
||||||
channel=dict(type='str', required=True),
|
channel=dict(type='str', required=True),
|
||||||
property=dict(type='str', required=True),
|
property=dict(type='str', required=True),
|
||||||
value_type=dict(type='list', elements='str',
|
value_type=dict(type='list', elements='str',
|
||||||
@@ -191,8 +191,6 @@ class XFConfProperty(StateModuleHelper):
|
|||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
default_state = 'present'
|
|
||||||
|
|
||||||
def __init_module__(self):
|
def __init_module__(self):
|
||||||
self.runner = xfconf_runner(self.module)
|
self.runner = xfconf_runner(self.module)
|
||||||
self.vars.version = get_xfconf_version(self.runner)
|
self.vars.version = get_xfconf_version(self.runner)
|
||||||
@@ -208,8 +206,8 @@ class XFConfProperty(StateModuleHelper):
|
|||||||
self.do_raise('xfconf-query failed with error (rc={0}): {1}'.format(rc, err))
|
self.do_raise('xfconf-query failed with error (rc={0}): {1}'.format(rc, err))
|
||||||
|
|
||||||
result = out.rstrip()
|
result = out.rstrip()
|
||||||
if "Value is an array with" in result:
|
if 'Value is an array with' in result:
|
||||||
result = result.split("\n")
|
result = result.split('\n')
|
||||||
result.pop(0)
|
result.pop(0)
|
||||||
result.pop(0)
|
result.pop(0)
|
||||||
|
|
||||||
@@ -225,7 +223,7 @@ class XFConfProperty(StateModuleHelper):
|
|||||||
self.vars.stdout = ctx.results_out
|
self.vars.stdout = ctx.results_out
|
||||||
self.vars.stderr = ctx.results_err
|
self.vars.stderr = ctx.results_err
|
||||||
self.vars.cmd = ctx.cmd
|
self.vars.cmd = ctx.cmd
|
||||||
self.vars.set("run_info", ctx.run_info, verbosity=4)
|
self.vars.set('run_info', ctx.run_info, verbosity=4)
|
||||||
self.vars.value = None
|
self.vars.value = None
|
||||||
|
|
||||||
def state_present(self):
|
def state_present(self):
|
||||||
@@ -255,7 +253,7 @@ class XFConfProperty(StateModuleHelper):
|
|||||||
self.vars.stdout = ctx.results_out
|
self.vars.stdout = ctx.results_out
|
||||||
self.vars.stderr = ctx.results_err
|
self.vars.stderr = ctx.results_err
|
||||||
self.vars.cmd = ctx.cmd
|
self.vars.cmd = ctx.cmd
|
||||||
self.vars.set("run_info", ctx.run_info, verbosity=4)
|
self.vars.set('run_info', ctx.run_info, verbosity=4)
|
||||||
|
|
||||||
if not self.vars.is_array:
|
if not self.vars.is_array:
|
||||||
self.vars.value = self.vars.value[0]
|
self.vars.value = self.vars.value[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user