created common.py for extracting deep comparision function.

This commit is contained in:
Shailaja Kumari 2024-06-04 05:45:28 +05:30
parent 31c955c5b9
commit d6717a9adf
Signed by: shailaja
GPG Key ID: 2B9455CAFBC4D75A
2 changed files with 15 additions and 3 deletions

View File

@ -0,0 +1,14 @@
import json
def deep_equal(a, b):
"""
Compare two data structures for deep equality by converting them to JSON strings.
Parameters:
a (any): First data structure to compare.
b (any): Second data structure to compare.
Returns:
bool: True if the two data structures are equal, False otherwise.
"""
return json.dumps(a, sort_keys=True) == json.dumps(b, sort_keys=True)

View File

@ -151,11 +151,9 @@ response:
'''
from ansible_collections.community.syncthing.plugins.module_utils.syncthing_api import SyncthingModule
from common.py import deep_equal
import json
def deep_equal(a, b):
return json.dumps(a, sort_keys=True) == json.dumps(b, sort_keys=True)
def run_module():
module_args = dict(
addresses=dict(type='list', required=False),