Move get_base_utils helper to entity base utils

merge-requests/131/head
Jason Robinson 2018-07-31 23:23:31 +03:00
rodzic 3bf4f01575
commit a464383c63
2 zmienionych plików z 15 dodań i 14 usunięć

Wyświetl plik

@ -35,20 +35,6 @@ def struct_to_xml(node, struct):
etree.SubElement(node, k).text = v
def get_base_attributes(entity):
"""Build a dict of attributes of an entity.
Returns attributes and their values, ignoring any properties, functions and anything that starts
with an underscore.
"""
attributes = {}
cls = entity.__class__
for attr, _ in inspect.getmembers(cls, lambda o: not isinstance(o, property) and not inspect.isroutine(o)):
if not attr.startswith("_"):
attributes[attr] = getattr(entity, attr)
return attributes
def get_full_xml_representation(entity, private_key):
"""Get full XML representation of an entity.

Wyświetl plik

@ -0,0 +1,15 @@
import inspect
def get_base_attributes(entity):
"""Build a dict of attributes of an entity.
Returns attributes and their values, ignoring any properties, functions and anything that starts
with an underscore.
"""
attributes = {}
cls = entity.__class__
for attr, _ in inspect.getmembers(cls, lambda o: not isinstance(o, property) and not inspect.isroutine(o)):
if not attr.startswith("_"):
attributes[attr] = getattr(entity, attr)
return attributes