- def add_rule_context_to_rspec(self,arguments, doc):
- p = doc.xpathNewContext()
- context = p.xpathEval("//rspec")
- if (not context):
- raise Exception('Request is not an rspec')
- else:
- # Add the request context
- ruleNode = libxml2.newNode('rule-context')
- ac = self.active_context
- for k in ac:
- argumentNode = libxml2.newNode('argument')
- nameNode = libxml2.newNode('name')
- nameNode.addContent(k)
- valueNode = libxml2.newNode('value')
- valueNode.addContent(ac[k])
- argumentNode.addChild(nameNode)
- argumentNode.addChild(valueNode)
- ruleNode.addChild(argumentNode)
- context[0].addChild(ruleNode)
- p.xpathFreeContext()
+
+ def apply(self, rspec):
+ if (self.sorted_rule_list):
+ doc = libxml2.parseDoc(rspec)
+ doc = self.add_request_context_to_rspec(doc)