Skip to content
Snippets Groups Projects
Commit 2f29b009 authored by Frede H's avatar Frede H :speech_balloon:
Browse files

reorderd

parent ef6cc9f8
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,32 @@ from . import txt
from . import configuration as conf
def api_write_branch(branch, filename):
"""Write branch"""
branch = "Branch = {}".format(branch)
try:
with open(
filename) as cnf, tempfile.NamedTemporaryFile(
"w+t", dir=os.path.dirname(
filename), delete=False) as tmp:
replaced = False
for line in cnf:
if "Branch" in line:
tmp.write(branch)
replaced = True
else:
tmp.write("{}".format(line))
if not replaced:
tmp.write(branch)
os.replace(tmp.name, filename)
os.chmod(filename, 0o644)
except OSError as err:
print(".: {} {}: {}: {}".format(txt.ERR_CLR, txt.CANNOT_READ_FILE,
err.filename, err.strerror))
exit(1)
def build_config():
"""Get config informations
:returns: config, custom
......@@ -102,32 +128,6 @@ def modify_config(config, custom=False):
custom=custom)
def api_write_branch(branch, filename):
"""Write branch"""
branch = "Branch = {}".format(branch)
try:
with open(
filename) as cnf, tempfile.NamedTemporaryFile(
"w+t", dir=os.path.dirname(
filename), delete=False) as tmp:
replaced = False
for line in cnf:
if "Branch" in line:
tmp.write(branch)
replaced = True
else:
tmp.write("{}".format(line))
if not replaced:
tmp.write(branch)
os.replace(tmp.name, filename)
os.chmod(filename, 0o644)
except OSError as err:
print(".: {} {}: {}: {}".format(txt.ERR_CLR, txt.CANNOT_READ_FILE,
err.filename, err.strerror))
exit(1)
def write_configuration(filename, selection, custom=False):
"""Writes the configuration to file
:param filename:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment