Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: Container Registry, Job Artifacs,. Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 04ec04d9 authored by LammLukas's avatar LammLukas
Browse files

Included get_attributes function in data2dict function of exportable class.

parent e74954ab
......@@ -14,23 +14,21 @@ class Exportable(object):
def data2dict(self):
"""Store attributes in dictionary for .json export
todo: include get_attributes function
"""
data = {}
for a in dir(self):
if not a.startswith('__') and not callable(getattr(self, a)):
attribute = getattr(self, a)
if isinstance(attribute, list):
if attribute and isinstance(attribute[0], Exportable):
item_list = []
for item in attribute:
item_data = item.data2dict()
item_list.append(item_data)
data[a] = item_list
else:
data[a] = attribute
for attr_name in self.get_attributes():
attribute = getattr(self, attr_name)
if isinstance(attribute, list):
if attribute and isinstance(attribute[0], Exportable):
item_list = []
for item in attribute:
item_data = item.data2dict()
item_list.append(item_data)
data[attr_name] = item_list
else:
data[a] = attribute
data[attr_name] = attribute
else:
data[attr_name] = attribute
return data
def write_json(self, file):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment