a little nicer wrt pep8
[sfa.git] / sfatables / xmlextension.py
index 1e27e76..dcc0419 100644 (file)
@@ -5,17 +5,17 @@
 #   - The parameters that the processor needs to evaluate the context
 
 import libxml2
-from sfatables.globals import *
 
 class Xmlextension:
-    context = ""
-    processor = ""
-    operand = "VALUE"
-    arguments = []
+    def __init__(self, file_path):
 
-    def __init__(self, dir, component_name):
-        filename = dir+"/"+component_name+".xml"
-        self.xmldoc = libxml2.parseFile(filename)
+        self.context = ""
+        self.processor = ""
+        self.operand = "VALUE"
+        self.arguments = []
+        self.terminal = 0
+
+        self.xmldoc = libxml2.parseFile(file_path)
 
         # TODO: Check xmldoc against a schema
         p = self.xmldoc.xpathNewContext()
@@ -34,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()