kopia lustrzana https://gitlab.com/jaywink/federation
Move get_base_utils helper to entity base utils
rodzic
3bf4f01575
commit
a464383c63
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
Ładowanie…
Reference in New Issue