From aed992e317378569abfdc75e0da195e56445db19 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 28 Jun 2013 23:47:27 +0200 Subject: Revert "Avoid use of lxml-only getparent()" This reverts commit 38f55b6257ce51b1cf65ecb3d980d7528c1b53ff. --- src/lib/Bcfg2/Client/Frame.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/lib/Bcfg2/Client/Frame.py') diff --git a/src/lib/Bcfg2/Client/Frame.py b/src/lib/Bcfg2/Client/Frame.py index 6bef77081..edbc9f055 100644 --- a/src/lib/Bcfg2/Client/Frame.py +++ b/src/lib/Bcfg2/Client/Frame.py @@ -207,7 +207,12 @@ class Frame(object): # take care of important entries first if not self.dryrun: - for parent in self.config.findall(".//Path/.."): + for cfile in self.config.findall(".//Path"): + if (cfile.get('name') not in self.__important__ or + cfile.get('type') != 'file' or + cfile not in self.whitelist): + continue + parent = cfile.getparent() if ((parent.tag == "Bundle" and ((self.setup['bundle'] and parent.get("name") not in self.setup['bundle']) or @@ -216,15 +221,9 @@ class Frame(object): (parent.tag == "Independent" and (self.setup['bundle'] or self.setup['skipindep']))): continue - for cfile in parent.findall("./Path"): - if (cfile.get('name') not in self.__important__ or - cfile.get('type') != 'file' or - cfile not in self.whitelist): - continue - tools = [t for t in self.tools - if t.handlesEntry(cfile) and t.canVerify(cfile)] - if not tools: - continue + tools = [t for t in self.tools + if t.handlesEntry(cfile) and t.canVerify(cfile)] + if tools: if (self.setup['interactive'] and not self.promptFilter("Install %s: %s? (y/N):", [cfile])): self.whitelist.remove(cfile) -- cgit v1.2.3-1-g7c22 From c715a661fece0e2e561d4d62a27e9bdac212c54a Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 28 Jun 2013 23:48:45 +0200 Subject: Client/Frame: avoid use of lxml-only getparent() getparent is not supported by xml.etree so try to emulate it with a generated parent_map. This is the only possibility, because xml.etree does not store references to the parent elements. --- src/lib/Bcfg2/Client/Frame.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Client/Frame.py') diff --git a/src/lib/Bcfg2/Client/Frame.py b/src/lib/Bcfg2/Client/Frame.py index edbc9f055..3254da9e9 100644 --- a/src/lib/Bcfg2/Client/Frame.py +++ b/src/lib/Bcfg2/Client/Frame.py @@ -207,12 +207,15 @@ class Frame(object): # take care of important entries first if not self.dryrun: + parent_map = dict((c, p) + for p in self.config.getiterator() + for c in p) for cfile in self.config.findall(".//Path"): if (cfile.get('name') not in self.__important__ or cfile.get('type') != 'file' or cfile not in self.whitelist): continue - parent = cfile.getparent() + parent = parent_map[cfile] if ((parent.tag == "Bundle" and ((self.setup['bundle'] and parent.get("name") not in self.setup['bundle']) or -- cgit v1.2.3-1-g7c22