Entropy/entropyTools:

- improve writeParameterToFile() by using regexps


git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@2092 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2008-06-03 00:29:13 +00:00
parent 41cc0bd488
commit 59d1f75019
+6 -4
View File
@@ -76,10 +76,10 @@ class TimeScheduled(threading.Thread):
self.function(self.data)
else:
self.function()
try:
try:
time.sleep(self.delay)
except:
pass
except:
pass
def kill(self):
self.alive = 0
@@ -1726,10 +1726,12 @@ def writeParameterToFile(config_file, name, data):
param_found = False
if data:
proposed_line = "%s|%s" % (name,data,)
myreg = re.compile('^(%s)?[|].*$' % (name,))
else:
proposed_line = "# %s|" % (name,)
myreg = re.compile('^#([ \t]+?)?(%s)?[|].*$' % (name,))
for line in content:
if line.startswith(name+"|"):
if myreg.match(line):
param_found = True
line = proposed_line
f.write(line+"\n")