From 5462b1cff88f19350ad5b310862d16e24b2c853f Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 28 Jun 2025 23:04:28 +1200 Subject: [PATCH] xfconf: small refactor (#10311) * xfconf: small refactor * add changelog frag * Update changelogs/fragments/10311-xfconf-refactor.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/10311-xfconf-refactor.yml | 2 ++ plugins/modules/xfconf.py | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/10311-xfconf-refactor.yml diff --git a/changelogs/fragments/10311-xfconf-refactor.yml b/changelogs/fragments/10311-xfconf-refactor.yml new file mode 100644 index 0000000000..9d71bd17d8 --- /dev/null +++ b/changelogs/fragments/10311-xfconf-refactor.yml @@ -0,0 +1,2 @@ +minor_changes: + - xfconf - minor adjustments the the code (https://github.com/ansible-collections/community.general/pull/10311). diff --git a/plugins/modules/xfconf.py b/plugins/modules/xfconf.py index a63ada665f..1cae7fb12b 100644 --- a/plugins/modules/xfconf.py +++ b/plugins/modules/xfconf.py @@ -178,7 +178,7 @@ class XFConfProperty(StateModuleHelper): output_params = ('property', 'channel', 'value') module = 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), property=dict(type='str', required=True), value_type=dict(type='list', elements='str', @@ -191,8 +191,6 @@ class XFConfProperty(StateModuleHelper): supports_check_mode=True, ) - default_state = 'present' - def __init_module__(self): self.runner = xfconf_runner(self.module) 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)) result = out.rstrip() - if "Value is an array with" in result: - result = result.split("\n") + if 'Value is an array with' in result: + result = result.split('\n') result.pop(0) result.pop(0) @@ -225,7 +223,7 @@ class XFConfProperty(StateModuleHelper): self.vars.stdout = ctx.results_out self.vars.stderr = ctx.results_err 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 def state_present(self): @@ -255,7 +253,7 @@ class XFConfProperty(StateModuleHelper): self.vars.stdout = ctx.results_out self.vars.stderr = ctx.results_err 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: self.vars.value = self.vars.value[0]