added helper function to convert objects to dicts
This commit is contained in:
parent
de16ce42ef
commit
49c54024e6
1 changed files with 6 additions and 0 deletions
|
@ -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
|
return int((value_pct / 100.0) * num_items) or min_value
|
||||||
else:
|
else:
|
||||||
return int(value)
|
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('__'))
|
||||||
|
|
Loading…
Reference in a new issue