mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
utils: Simplify YAMLFile by removing the post_exit argument
Whatever function is passed in post_exit can simply be called by the caller itself as the next statement. Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
938dadcae0
commit
753881b80f
3 files changed
+5
-9
No files matched your search
+1
-6
@@ -89,16 +89,14 @@ def get_domain_names():
|
||||
class YAMLFile(object):
|
||||
"""A context management class for updating YAML files"""
|
||||
|
||||
def __init__(self, yaml_file, post_exit=None):
|
||||
def __init__(self, yaml_file):
|
||||
"""Return a context object for the YAML file.
|
||||
|
||||
Parameters:
|
||||
yaml_file - the YAML file to update.
|
||||
post_exit - a function that will be called after
|
||||
updating the YAML file.
|
||||
"""
|
||||
self.yaml_file = yaml_file
|
||||
self.post_exit = post_exit
|
||||
self.conf = None
|
||||
|
||||
def __enter__(self):
|
||||
@@ -114,9 +112,6 @@ class YAMLFile(object):
|
||||
with open(self.yaml_file, 'w') as intro_conf:
|
||||
ruamel.yaml.round_trip_dump(self.conf, intro_conf)
|
||||
|
||||
if self.post_exit:
|
||||
self.post_exit()
|
||||
|
||||
def is_file_empty(self):
|
||||
return os.stat(self.yaml_file).st_size == 0
|
||||
|
||||
|
||||
Reference in new issue
Block a user