aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2002-07-24 23:02:23 +0000
committerFrederic Lepied <flepied@mandriva.com>2002-07-24 23:02:23 +0000
commite5dcc59c1af9be91b37b6568232835cf724e4912 (patch)
treeb7ca7ea799f9f1c279af1ffdbf1399cd4f0c841a
parent119213f6b2a43d2dfd8aab15bed42f5359dffb69 (diff)
downloadmsec-e5dcc59c1af9be91b37b6568232835cf724e4912.tar
msec-e5dcc59c1af9be91b37b6568232835cf724e4912.tar.gz
msec-e5dcc59c1af9be91b37b6568232835cf724e4912.tar.bz2
msec-e5dcc59c1af9be91b37b6568232835cf724e4912.tar.xz
msec-e5dcc59c1af9be91b37b6568232835cf724e4912.zip
* (ConfigFile.get_match): return the whole line if replace is None.
-rw-r--r--share/ConfigFile.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/share/ConfigFile.py b/share/ConfigFile.py
index 40ee8f6..64ba296 100644
--- a/share/ConfigFile.py
+++ b/share/ConfigFile.py
@@ -244,7 +244,7 @@ class ConfigFile:
def get_shell_variable(self, var):
regex = re.compile('^' + var + '="?([^#"]+)"?(.*)')
lines = self.get_lines()
- for idx in range(0, len(lines)):
+ for idx in range(len(lines) - 1, -1, -1):
res = regex.search(lines[idx])
if res:
return res.group(1)
@@ -256,8 +256,11 @@ class ConfigFile:
for idx in range(0, len(lines)):
res = r.search(lines[idx])
if res:
- s = substitute_re_result(res, replace)
- return s
+ if replace:
+ s = substitute_re_result(res, replace)
+ return s
+ else:
+ return lines[idx]
return None
def replace_line_matching(self, regex, value, at_end_if_not_found=0, all=0, start=None, end=None):