Improve setting dump serialization.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-08-19 03:50:15 -04:00
parent 90cd142e76
commit 885be348d4
2 changed files with 8 additions and 19 deletions
+6 -13
View File
@@ -92,21 +92,14 @@ class Setting(object):
@classmethod
def dump_data(cls):
result = []
dictionary = {}
for setting in cls.get_all():
# Ensure there is at least one newline
line = '{}: {}\n'.format(
setting.global_name, setting.serialized_value
)
if setting.quoted:
dictionary[setting.global_name] = '{}'.format(setting.value)
else:
dictionary[setting.global_name] = setting.value
# If there are two newlines, remove one
if line.endswith('\n\n'):
line = line[:-1]
result.append(line)
return ''.join(result)
return yaml.safe_dump(dictionary)
@classmethod
def get(cls, global_name):