Yaniv Bronhaim has posted comments on this change. Change subject: configfile utility for common config file editing operations. ......................................................................
Patch Set 1: (3 comments) http://gerrit.ovirt.org/#/c/27129/1/lib/vdsm/tool/configfile.py File lib/vdsm/tool/configfile.py: Line 48: def getOldContent(self): Line 49: confpat = re.compile(r'^\s*([^=\s]*)\s*=') Line 50: oldlines = [] Line 51: oldentries = set() Line 52: with open(self.filename, 'r') as f: handle exceptions here.. Line 53: for line in f: Line 54: if self.remove: Line 55: if self.rmstate == BEFORE and\ Line 56: line.startswith(self.confstart): Line 67: line = self.prefix + line Line 68: oldlines.append(line) Line 69: return oldlines, oldentries Line 70: Line 71: def __exit__(self, exec_ty, exec_val, tb): > you can call it "flush" or "commit", and them assume you start new config, after checking the tests, it does look nice to use it in contexts . +1 for this approach Line 72: Line 73: self.context = OUT Line 74: if exec_ty is None: Line 75: fd, tname = tempfile.mkstemp(dir=os.path.dirname(self.filename)) Line 101: """ Line 102: if self.context == IN: Line 103: self.entries[key] = val Line 104: else: Line 105: raise RuntimeError("Internal error") print "'addEntry' must be run in Config context", move clear than Internal Error Line 106: Line 107: def prependSection(self, section): Line 108: """ Line 109: add 'section' in the beginning of the file. -- To view, visit http://gerrit.ovirt.org/27129 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: If8c7ae2b562650e403fc39024f3531d44b2b9c4f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: mooli tayer <[email protected]> Gerrit-Reviewer: Saggi Mizrahi <[email protected]> Gerrit-Reviewer: Yaniv Bronhaim <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
