Alex Lourie has uploaded a new change for review. Change subject: packaging: Adding utility functions ......................................................................
packaging: Adding utility functions * Added a renameParam function that allows renaming a param in a TextConfig file. * Implemented a delParams function that will comment out a list of params provided, if they are defined. Change-Id: I5740ab71597781f3995087ad29c85cde8c1e555a Signed-off-by: Alex Lourie <[email protected]> --- M packaging/fedora/setup/common_utils.py 1 file changed, 25 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/56/9856/1 diff --git a/packaging/fedora/setup/common_utils.py b/packaging/fedora/setup/common_utils.py index 84468aa..78ede16 100755 --- a/packaging/fedora/setup/common_utils.py +++ b/packaging/fedora/setup/common_utils.py @@ -110,6 +110,22 @@ value = found.group(1) return value + def renameParam(self, current_param_name, new_param_name): + if current_param_name == new_param_name: + return + changed = False + for i, line in enumerate(self.data[:]): + if not re.match("\s*#", line): + if re.match("\s*%s"%(new_param_name), line): + changed = True + break + if re.match("\s*%s"%(current_param_name), line): + self.data[i] = line.replace(current_param_name, new_param_name) + changed = True + break + if not changed: + self.data.append("%s%s\n"%(new_param_name, self.sep)) + def editParam(self, param, value, uncomment=False): change_index = -1 @@ -165,7 +181,15 @@ logging.warn(errMsg) def delParams(self, paramsDict): - pass + ''' + This function will comment out the params provided by paramsDict + ''' + + # Find the index of the line containing the parameter that + # we want to modify: + for param in paramsDict: + if self.getParam(param): + self.renameParam(param, "#" + param) class XMLConfigFileHandler(ConfigFileHandler): def __init__(self, filepath): -- To view, visit http://gerrit.ovirt.org/9856 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5740ab71597781f3995087ad29c85cde8c1e555a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alex Lourie <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
