X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fxmlextension.py;h=dcc04190ec2b919bde71f2845ccaad65cdba8e6c;hb=4a9e6751f9f396f463932133b9d62fc925a99ef6;hp=c852a268cb6ec1ecc998002a88e4becb9d103732;hpb=c18d4a0349f3e8bbfbe4b7efcf1ce031a1c06fd7;p=sfa.git diff --git a/sfatables/xmlextension.py b/sfatables/xmlextension.py index c852a268..dcc04190 100644 --- a/sfatables/xmlextension.py +++ b/sfatables/xmlextension.py @@ -6,17 +6,16 @@ import libxml2 -match_dir = 'matches' - class Xmlextension: - context = "" - processor = "" - operand = "VALUE" - arguments = [] + def __init__(self, file_path): + + self.context = "" + self.processor = "" + self.operand = "VALUE" + self.arguments = [] + self.terminal = 0 - def __init__(self, component_name): - filename = match_dir+"/"+component_name+".xml" - self.xmldoc = libxml2.parseFile(filename) + self.xmldoc = libxml2.parseFile(file_path) # TODO: Check xmldoc against a schema p = self.xmldoc.xpathNewContext() @@ -35,7 +34,10 @@ class Xmlextension: help = p.xpathEval('//rule/argument/help') target = p.xpathEval('//rule/argument/operand') - self.arguments = map(lambda (name,help,target):{'name':name.content,'help':help.content,'target':target.content}, zip(name,help,target)) + context = p.xpathEval('//attributes/attribute[@terminal="yes"]') + self.terminal = (context != []) + + self.arguments = [{'name':name_help_target[0].content,'help':name_help_target[1].content,'target':name_help_target[2].content} for name_help_target in zip(name,help,target)] p.xpathFreeContext() self.xmldoc.freeDoc()