From e04541587a46b494647f41071c738522a0bcee28 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 23 Sep 2013 16:14:38 +0000 Subject: [PATCH] Do a regular expression replace instead of exact string search and replace. --- common/tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/tools.py b/common/tools.py index b7988cb..7bd4fbc 100644 --- a/common/tools.py +++ b/common/tools.py @@ -51,12 +51,13 @@ def sed_i(file_path, pattern, subst): from shutil import move from os import close import os + import re temp_fd, temp_path = mkstemp() mode = os.stat(file_path).st_mode with open(temp_path, 'w') as new_file: with open(file_path) as old_file: for line in old_file: - new_file.write(line.replace(pattern, subst)) + new_file.write(re.sub(pattern, subst, line)) close(temp_fd) os.chmod(temp_path, mode) move(temp_path, file_path)