mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-20 07:40:58 +00:00
follow suit with the rax refactor and split out the slugify code
This commit is contained in:
@@ -90,14 +90,16 @@ except ImportError:
|
||||
NON_CALLABLES = (basestring, bool, dict, int, list, NoneType)
|
||||
|
||||
|
||||
def rax_slugify(value):
|
||||
return 'rax_%s' % (re.sub('[^\w-]', '_', value).lower().lstrip('_'))
|
||||
|
||||
|
||||
def pyrax_object_to_dict(obj):
|
||||
instance = {}
|
||||
for key in dir(obj):
|
||||
value = getattr(obj, key)
|
||||
if (isinstance(value, NON_CALLABLES) and not key.startswith('_')):
|
||||
key = 'rax_' + (re.sub('[^A-Za-z0-9\-]', '_', key)
|
||||
.lower()
|
||||
.lstrip('_'))
|
||||
key = rax_slugify(key)
|
||||
instance[key] = value
|
||||
return instance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user