Refactoring
This commit is contained in:
@@ -386,8 +386,8 @@ def update_config(path, apply_update=True):
|
|||||||
if value != new_config.get(section, option, raw=True):
|
if value != new_config.get(section, option, raw=True):
|
||||||
update = True
|
update = True
|
||||||
new_config.set(section, option, value)
|
new_config.set(section, option, value)
|
||||||
|
if apply_update:
|
||||||
if update and apply_update:
|
if update:
|
||||||
# Backing up old config file
|
# Backing up old config file
|
||||||
date = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
|
date = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
|
||||||
dest = f"{os.path.splitext(path)[0]}_{date}.old"
|
dest = f"{os.path.splitext(path)[0]}_{date}.old"
|
||||||
@@ -404,14 +404,13 @@ def update_config(path, apply_update=True):
|
|||||||
os.chmod(dest, stat.S_IRUSR | stat.S_IWUSR)
|
os.chmod(dest, stat.S_IRUSR | stat.S_IWUSR)
|
||||||
|
|
||||||
return dest
|
return dest
|
||||||
elif update and not apply_update:
|
return None
|
||||||
|
else:
|
||||||
|
if update:
|
||||||
# Simply check if current config file is outdated
|
# Simply check if current config file is outdated
|
||||||
return True
|
return True
|
||||||
elif not update and not apply_update:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def gen_config(dest, interactive=False):
|
def gen_config(dest, interactive=False):
|
||||||
"""Create config file from dict template"""
|
"""Create config file from dict template"""
|
||||||
|
|||||||
Reference in New Issue
Block a user