mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-05 15:57:23 +01:00
mail seems to work
This commit is contained in:
@@ -17,16 +17,33 @@ buf = ""
|
||||
for line in open(filename):
|
||||
for i in range(len(settings)):
|
||||
name, val = settings[i].split("=", 1)
|
||||
if re.match("\s*" + re.escape(name) + "\s*=", line):
|
||||
m = re.match("\s*" + re.escape(name) + "\s*=\s*(.*?)\s*$", line)
|
||||
if m:
|
||||
# If this is already the setting, do nothing.
|
||||
if m.group(1) == val:
|
||||
buf += line
|
||||
found.add(i)
|
||||
break
|
||||
|
||||
# comment-out the existing line
|
||||
buf += "#" + line
|
||||
if i in found: break # we've already set the directive
|
||||
|
||||
# if this option oddly appears more than once, don't add the settingg again
|
||||
if i in found:
|
||||
break
|
||||
|
||||
# add the new setting
|
||||
buf += name + "=" + val + "\n"
|
||||
|
||||
# note that we've applied this option
|
||||
found.add(i)
|
||||
|
||||
break
|
||||
else:
|
||||
# did not match any setting name
|
||||
# If did not match any setting names, pass this line through.
|
||||
buf += line
|
||||
|
||||
# Put any settings we didn't see at the end of the file.
|
||||
for i in range(len(settings)):
|
||||
if i not in found:
|
||||
buf += settings[i] + "\n"
|
||||
|
||||
Reference in New Issue
Block a user