From 49c54024e6636580f59269d4c6a4072c0894f1b7 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 18 Aug 2017 13:44:10 -0400 Subject: [PATCH] added helper function to convert objects to dicts --- lib/ansible/utils/helpers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/utils/helpers.py b/lib/ansible/utils/helpers.py index 0ecb160813..ecb5d0c96a 100644 --- a/lib/ansible/utils/helpers.py +++ b/lib/ansible/utils/helpers.py @@ -32,3 +32,9 @@ def pct_to_int(value, num_items, min_value=1): return int((value_pct / 100.0) * num_items) or min_value else: return int(value) + +def object_to_dict(obj): + """ + Converts an object into a dict making the properties into keys + """ + return dict((key, getattr(obj, key)) for key in dir(obj) if not key.startswith('__'))