mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* remove redundant XfConfException class
* adjusted indentation in the documentaiton blocks
* add changelog fragment
(cherry picked from commit 31ef6c914b
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
695599e7d5
commit
6e685e740e
3 changed files with 32 additions and 35 deletions
3
changelogs/fragments/4975-xfconf-use-do-raise.yaml
Normal file
3
changelogs/fragments/4975-xfconf-use-do-raise.yaml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
minor_changes:
|
||||||
|
- xfconf - use ``do_raise()`` instead of defining custom exception class (https://github.com/ansible-collections/community.general/pull/4975).
|
||||||
|
- xfconf_info - use ``do_raise()`` instead of defining custom exception class (https://github.com/ansible-collections/community.general/pull/4975).
|
|
@ -149,10 +149,6 @@ from ansible_collections.community.general.plugins.module_utils.module_helper im
|
||||||
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner
|
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner
|
||||||
|
|
||||||
|
|
||||||
class XFConfException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class XFConfProperty(StateModuleHelper):
|
class XFConfProperty(StateModuleHelper):
|
||||||
change_params = 'value',
|
change_params = 'value',
|
||||||
diff_params = 'value',
|
diff_params = 'value',
|
||||||
|
@ -194,7 +190,7 @@ class XFConfProperty(StateModuleHelper):
|
||||||
if err.rstrip() == self.does_not:
|
if err.rstrip() == self.does_not:
|
||||||
return None
|
return None
|
||||||
if rc or len(err):
|
if rc or len(err):
|
||||||
raise XFConfException('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:
|
||||||
|
@ -227,7 +223,7 @@ class XFConfProperty(StateModuleHelper):
|
||||||
value_type = value_type * values_len
|
value_type = value_type * values_len
|
||||||
elif types_len != values_len:
|
elif types_len != values_len:
|
||||||
# or complain if lists' lengths are different
|
# or complain if lists' lengths are different
|
||||||
raise XFConfException('Number of elements in "value" and "value_type" must be the same')
|
self.do_raise('Number of elements in "value" and "value_type" must be the same')
|
||||||
|
|
||||||
# calculates if it is an array
|
# calculates if it is an array
|
||||||
self.vars.is_array = \
|
self.vars.is_array = \
|
||||||
|
|
|
@ -9,7 +9,7 @@ __metaclass__ = type
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
module: xfconf_info
|
module: xfconf_info
|
||||||
author:
|
author:
|
||||||
- "Alexei Znamensky (@russoz)"
|
- "Alexei Znamensky (@russoz)"
|
||||||
short_description: Retrieve XFCE4 configurations
|
short_description: Retrieve XFCE4 configurations
|
||||||
version_added: 3.5.0
|
version_added: 3.5.0
|
||||||
description:
|
description:
|
||||||
|
@ -61,8 +61,8 @@ EXAMPLES = """
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
channels:
|
channels:
|
||||||
description:
|
description:
|
||||||
- List of available channels.
|
- List of available channels.
|
||||||
- Returned when the module receives no parameter at all.
|
- Returned when the module receives no parameter at all.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
|
@ -73,57 +73,53 @@ RETURN = '''
|
||||||
- xfwm4
|
- xfwm4
|
||||||
properties:
|
properties:
|
||||||
description:
|
description:
|
||||||
- List of available properties for a specific channel.
|
- List of available properties for a specific channel.
|
||||||
- Returned by passing only the I(channel) parameter to the module.
|
- Returned by passing only the I(channel) parameter to the module.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
sample:
|
sample:
|
||||||
- /Gdk/WindowScalingFactor
|
- /Gdk/WindowScalingFactor
|
||||||
- /Gtk/ButtonImages
|
- /Gtk/ButtonImages
|
||||||
- /Gtk/CursorThemeSize
|
- /Gtk/CursorThemeSize
|
||||||
- /Gtk/DecorationLayout
|
- /Gtk/DecorationLayout
|
||||||
- /Gtk/FontName
|
- /Gtk/FontName
|
||||||
- /Gtk/MenuImages
|
- /Gtk/MenuImages
|
||||||
- /Gtk/MonospaceFontName
|
- /Gtk/MonospaceFontName
|
||||||
- /Net/DoubleClickTime
|
- /Net/DoubleClickTime
|
||||||
- /Net/IconThemeName
|
- /Net/IconThemeName
|
||||||
- /Net/ThemeName
|
- /Net/ThemeName
|
||||||
- /Xft/Antialias
|
- /Xft/Antialias
|
||||||
- /Xft/Hinting
|
- /Xft/Hinting
|
||||||
- /Xft/HintStyle
|
- /Xft/HintStyle
|
||||||
- /Xft/RGBA
|
- /Xft/RGBA
|
||||||
is_array:
|
is_array:
|
||||||
description:
|
description:
|
||||||
- Flag indicating whether the property is an array or not.
|
- Flag indicating whether the property is an array or not.
|
||||||
returned: success
|
returned: success
|
||||||
type: bool
|
type: bool
|
||||||
value:
|
value:
|
||||||
description:
|
description:
|
||||||
- The value of the property. Empty if the property is of array type.
|
- The value of the property. Empty if the property is of array type.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sample: Monospace 10
|
sample: Monospace 10
|
||||||
value_array:
|
value_array:
|
||||||
description:
|
description:
|
||||||
- The array value of the property. Empty if the property is not of array type.
|
- The array value of the property. Empty if the property is not of array type.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
sample:
|
sample:
|
||||||
- Main
|
- Main
|
||||||
- Work
|
- Work
|
||||||
- Tmp
|
- Tmp
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
|
||||||
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner
|
from ansible_collections.community.general.plugins.module_utils.xfconf import xfconf_runner
|
||||||
|
|
||||||
|
|
||||||
class XFConfException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class XFConfInfo(ModuleHelper):
|
class XFConfInfo(ModuleHelper):
|
||||||
module = dict(
|
module = dict(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
|
@ -170,8 +166,10 @@ class XFConfInfo(ModuleHelper):
|
||||||
elif self.vars.property is None:
|
elif self.vars.property is None:
|
||||||
output = 'properties'
|
output = 'properties'
|
||||||
proc = self._process_list_properties
|
proc = self._process_list_properties
|
||||||
|
|
||||||
with self.runner.context('list_arg channel property', output_process=proc) as ctx:
|
with self.runner.context('list_arg channel property', output_process=proc) as ctx:
|
||||||
result = ctx.run(**self.vars)
|
result = ctx.run(**self.vars)
|
||||||
|
|
||||||
if not self.vars.list_arg and self.vars.is_array:
|
if not self.vars.list_arg and self.vars.is_array:
|
||||||
output = "value_array"
|
output = "value_array"
|
||||||
self.vars.set(output, result)
|
self.vars.set(output, result)
|
||||||
|
|
Loading…
Reference in a new issue