Juan Hernandez has posted comments on this change.
Change subject: packaging: Adding utility functions
......................................................................
Patch Set 1: (3 inline comments)
....................................................
File packaging/fedora/setup/common_utils.py
Line 114: if current_param_name == new_param_name:
Line 115: return
Line 116: changed = False
Line 117: for i, line in enumerate(self.data[:]):
Line 118: if not re.match("\s*#", line):
I think this should be "\s*%s" % comment.
Line 119: if re.match("\s*%s"%(new_param_name), line):
Line 120: changed = True
Line 121: break
Line 122: if re.match("\s*%s"%(current_param_name), line):
Line 121: break
Line 122: if re.match("\s*%s"%(current_param_name), line):
Line 123: self.data[i] = line.replace(current_param_name,
new_param_name)
Line 124: changed = True
Line 125: break
The regular expressions that you are using here will match any parameter whose
name starts with new_param_name or current_param_name, so if for example
current_param_name is "a" this will rename the first parameter in the file
whose name *starts* with "a".
I think you can avoid this building the regular expression as follows (similar
to what we do in the getParam method):
"\s*%s\s*%s" % (current_param_name, self.sep)
Line 126: if not changed:
Line 127: self.data.append("%s%s\n"%(new_param_name, self.sep))
Line 128:
Line 129: def editParam(self, param, value, uncomment=False):
Line 188: # Find the index of the line containing the parameter that
Line 189: # we want to modify:
Line 190: for param in paramsDict:
Line 191: if self.getParam(param):
Line 192: self.renameParam(param, "#" + param)
comment + param?
Line 193:
Line 194: class XMLConfigFileHandler(ConfigFileHandler):
Line 195: def __init__(self, filepath):
Line 196: ConfigFileHandler.__init__(self, filepath)
--
To view, visit http://gerrit.ovirt.org/9856
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I5740ab71597781f3995087ad29c85cde8c1e555a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alex Lourie <[email protected]>
Gerrit-Reviewer: Alex Lourie <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Kiril Nesenko <[email protected]>
Gerrit-Reviewer: Moran Goldboim <[email protected]>
Gerrit-Reviewer: Ofer Schreiber <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches