From 362f65437b7201f31fac084055de3d0cc2709584 Mon Sep 17 00:00:00 2001 From: Christopher Harvey Date: Tue, 15 Jun 2010 01:28:29 -0400 Subject: Various bug fixes and rearragments in tree build. Working better, not perfect. --- src/ventoo/main.py | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/src/ventoo/main.py b/src/ventoo/main.py index e3ee2c8..9916a26 100644 --- a/src/ventoo/main.py +++ b/src/ventoo/main.py @@ -119,7 +119,7 @@ class MainWindow(gtk.Window): #print "insert("+augBeforePath+" "+re.match('^.+/(.+?)(?:\\[[0-9]+\\])?$', augPath).group(1)+")" self.a.set(augPath, '') else: #this row was deleted, update augeas tree in the refresh - print 'Would remove ' + augPath + #print 'Would remove ' + augPath self.a.remove(augPath) self.refreshAugeasEditTree() @@ -313,8 +313,16 @@ class MainWindow(gtk.Window): matches = list(set(matches)) #remove dups from matches listedNodes.extend(matches) + for match in matches: + userData = self.a.get(match) #add all existing data + if userData == None: + userData = '' + created = model.append(modelPathIter, [True, osp.split(match)[1], userData]) + self.__buildEditModel(model, match, created, osp.join(xmlRoot, child.tag)) + #add leaves if we're missing some required ones (in augeas itself) have = len(matches) + toAddtoHave = 0 numNeeded = augeas_utils.matchDiff(childMult, have) for i in range(have+1, have+numNeeded+1): p = osp.join(augeasFileRoot, child.tag) @@ -322,38 +330,16 @@ class MainWindow(gtk.Window): p = p + '[' + str(i) + ']' print 'added ' + p + ' to augeas' self.a.set(p, '') + toAddtoHave += 1 + have += toAddtoHave - #update the matches, since we have added stuff to augeas, based on previous matches - matches = self.a.match(osp.join(augeasFileRoot, child.tag)) - matches.extend(self.a.match(osp.join(augeasFileRoot, child.tag)+'[*]')) - matches = list(set(matches)) #remove dups from matches - for match in matches: - userData = self.a.get(match) #add all existing data - if userData == None: - userData = '' - created = model.append(modelPathIter, [True, osp.split(match)[1], userData]) - self.__buildEditModel(model, match, created, osp.join(xmlRoot, child.tag)) #maybe we need to add more of child to the tree, and maybe even an option for the user. - have = len(matches) + #this code is different from the rest because it doesn't update the augeas tree, it only + #tells the user that the tree COULD be undated along this 'child' variable/branch. needed = not augeas_utils.matchExact(childMult, have) - numNeeded = augeas_utils.matchDiff(childMult, have) if needed: - i = 0 - while True: - foo = True - if numNeeded == 0: - foo = False - newLabel = child.tag - if True: - newLabel = newLabel + '['+str(have+i+1)+']' - created = model.append(modelPathIter, [foo, newLabel, '']) - if foo: - self.__buildEditModel(model, 'no_data', created, osp.join(xmlRoot, child.tag)) - i += 1 - if augeas_utils.matchExact(childMult, have+i): - break - if not foo: - break + created = model.append(modelPathIter, [False, child.tag + '[' + str(have+1) + ']', '']) + #now search for and add nodes that haven't been added yet, and may not be in the VentooModule specifically. allInAugeas = self.a.match(osp.join(augeasFileRoot, '*')) lastLineWasDoc = False -- cgit v1.2.3-65-gdbad