|
|
@ -102,7 +102,7 @@ class YamlSerializable(object): |
|
|
|
|
|
|
|
|
|
|
|
ymlsls = [] |
|
|
|
ymlsls = [] |
|
|
|
for ymlsl_dict in ymlsl_dicts: |
|
|
|
for ymlsl_dict in ymlsl_dicts: |
|
|
|
ymlsls.append(cls._ymlserializable_from_dict(ymlsl_dict)) |
|
|
|
ymlsls.append(cls._from_dict(ymlsl_dict)) |
|
|
|
return ymlsls |
|
|
|
return ymlsls |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
@ -115,18 +115,18 @@ class YamlSerializable(object): |
|
|
|
return ymlserializables_list |
|
|
|
return ymlserializables_list |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def _ymlserializable_from_dict(cls, ymldict): |
|
|
|
def _from_dict(cls, ymldict): |
|
|
|
if ymldict is None: |
|
|
|
if ymldict is None: |
|
|
|
return None |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
# Extract the name |
|
|
|
# Extract the name |
|
|
|
ymlserializable_name = [*ymldict][0] |
|
|
|
ymlsl_name = [*ymldict][0] |
|
|
|
|
|
|
|
|
|
|
|
# Step into object |
|
|
|
# Step into object |
|
|
|
ymldict = ymldict.get(ymlserializable_name) |
|
|
|
ymldict = ymldict.get(ymlsl_name) |
|
|
|
|
|
|
|
|
|
|
|
# Add name to dict |
|
|
|
# Add name to dict |
|
|
|
ymldict['name'] = ymlserializable_name |
|
|
|
ymldict['name'] = ymlsl_name |
|
|
|
|
|
|
|
|
|
|
|
# Create empty instance |
|
|
|
# Create empty instance |
|
|
|
ymlsl = cls() |
|
|
|
ymlsl = cls() |
|
|
@ -143,6 +143,6 @@ class YamlSerializable(object): |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def _save_all_to_file(cls, ymlsls): |
|
|
|
def _save_all_to_file(cls, ymlsls): |
|
|
|
ymlserializables_object = {cls._yaml_object_name() : ymlsls} |
|
|
|
ymlsls_object = {cls._yaml_object_name() : ymlsls} |
|
|
|
with open(cls._storage_file(), 'w') as file: |
|
|
|
with open(cls._storage_file(), 'w') as file: |
|
|
|
yaml.dump(ymlserializables_object, file) |
|
|
|
yaml.dump(ymlsls_object, file) |
|
|
|