1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-15 23:41:12 +00:00

migrate to yaml.safe_dump

This commit is contained in:
deadc0de6
2019-04-02 21:07:49 +02:00
parent 672d8c63a7
commit 15dd13f8b4
2 changed files with 10 additions and 5 deletions

View File

@@ -569,8 +569,9 @@ class Cfg:
"""writes the config to file""" """writes the config to file"""
ret = False ret = False
with open(path, 'w') as f: with open(path, 'w') as f:
ret = yaml.dump(content, f, ret = yaml.safe_dump(content, f,
default_flow_style=False, indent=2) default_flow_style=False,
indent=2)
return ret return ret
def _norm_key_elem(self, elem): def _norm_key_elem(self, elem):
@@ -827,7 +828,9 @@ class Cfg:
self.lnk_settings[self.key_dotpath] = self.curdotpath self.lnk_settings[self.key_dotpath] = self.curdotpath
self.lnk_settings[self.key_workdir] = self.curworkdir self.lnk_settings[self.key_workdir] = self.curworkdir
# dump # dump
ret = yaml.dump(self.content, default_flow_style=False, indent=2) ret = yaml.safe_dump(self.content,
default_flow_style=False,
indent=2)
ret = ret.replace('{}', '') ret = ret.replace('{}', '')
# restore paths # restore paths
self.lnk_settings[self.key_dotpath] = dotpath self.lnk_settings[self.key_dotpath] = dotpath

View File

@@ -79,7 +79,8 @@ class TestConfig(unittest.TestCase):
# save the new config # save the new config
with open(confpath, 'w') as f: with open(confpath, 'w') as f:
yaml.dump(content, f, default_flow_style=False, indent=2) yaml.safe_dump(content, f, default_flow_style=False,
indent=2)
# do the tests # do the tests
conf = Cfg(confpath) conf = Cfg(confpath)
@@ -109,7 +110,8 @@ class TestConfig(unittest.TestCase):
# save the new config # save the new config
with open(confpath, 'w') as f: with open(confpath, 'w') as f:
yaml.dump(content, f, default_flow_style=False, indent=2) yaml.safe_dump(content, f, default_flow_style=False,
indent=2)
# do the tests # do the tests
conf = Cfg(confpath) conf = Cfg(confpath)