mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-02 08:22:52 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -79,6 +79,7 @@ import importlib
|
|||
|
||||
try:
|
||||
import jc
|
||||
|
||||
HAS_LIB = True
|
||||
except ImportError:
|
||||
HAS_LIB = False
|
||||
|
|
@ -133,26 +134,28 @@ def jc_filter(data, parser, quiet=True, raw=False):
|
|||
"""
|
||||
|
||||
if not HAS_LIB:
|
||||
raise AnsibleError('You need to install "jc" as a Python library on the Ansible controller prior to running jc filter')
|
||||
raise AnsibleError(
|
||||
'You need to install "jc" as a Python library on the Ansible controller prior to running jc filter'
|
||||
)
|
||||
|
||||
try:
|
||||
# new API (jc v1.18.0 and higher) allows use of plugin parsers
|
||||
if hasattr(jc, 'parse'):
|
||||
if hasattr(jc, "parse"):
|
||||
return jc.parse(parser, data, quiet=quiet, raw=raw)
|
||||
|
||||
# old API (jc v1.17.7 and lower)
|
||||
else:
|
||||
jc_parser = importlib.import_module(f'jc.parsers.{parser}')
|
||||
jc_parser = importlib.import_module(f"jc.parsers.{parser}")
|
||||
return jc_parser.parse(data, quiet=quiet, raw=raw)
|
||||
|
||||
except Exception as e:
|
||||
raise AnsibleFilterError(f'Error in jc filter plugin: {e}')
|
||||
raise AnsibleFilterError(f"Error in jc filter plugin: {e}")
|
||||
|
||||
|
||||
class FilterModule:
|
||||
''' Query filter '''
|
||||
"""Query filter"""
|
||||
|
||||
def filters(self):
|
||||
return {
|
||||
'jc': jc_filter,
|
||||
"jc": jc_filter,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue