From e2c9e4ed6c83c285e1b39f359d3495c984ff010e Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Mon, 14 Dec 2009 23:28:58 +0000 Subject: [PATCH] initial checkin of merge method --- sfa/util/rspec.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sfa/util/rspec.py b/sfa/util/rspec.py index fab1b57e..515dd864 100644 --- a/sfa/util/rspec.py +++ b/sfa/util/rspec.py @@ -332,6 +332,28 @@ class RSpec: self.filter(tagname, attribute, blacklist, whitelist, child) + def merge(self, rspecs, tagname, dom=None): + """ + Merge this rspec with the requested rspec based on the specified + starting tag name. The start tag (and all of its children) will be merged + """ + tempdict = {} + if not dom: + dom = self.rootNode + + whitelist = [] + blacklist = [] + + if dom.localName in [tagname] and dom.attributes.has_key(attribute): + if whitelist and dom.attributes.get(attribute).value not in whitelist: + dom.parentNode.removeChild(dom) + if blacklist and dom.attributes.get(attribute).value in blacklist: + dom.parentNode.removeChild(dom) + + if dom.hasChildNodes(): + for child in dom.childNodes: + self.filter(tagname, attribute, blacklist, whitelist, child) + def validateDicts(self): types = { 'EInt' : int, -- 2.43.0