[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Begin implementing feature logic



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv14012/lib/mixminion

Modified Files:
	Config.py 
Log Message:
Begin implementing feature logic

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- Config.py	28 Sep 2003 05:27:56 -0000	1.58
+++ Config.py	6 Oct 2003 20:53:02 -0000	1.59
@@ -569,6 +569,7 @@
     #   will be set to None.
 
     _syntax = None
+    _features = {}
     _restrictFormat = 0
     _restrictKeys = 1
     _restrictSections = 1
@@ -734,6 +735,41 @@
            override.  Returns a revised version of its input.
         """
         return contents
+
+    def resolveFeatureName(self, name):
+        """DOCDOC"""
+        #XXXX006 this should be case insensitive.
+        syn = self._syntax
+        if self._features.has_key(name):
+            return "-", name
+        elif ':' in name:
+            idx = name.index(':')
+            sec, ent = name[:idx], name[idx+1:]
+            if not syn.has_key(sec) or not syn[sec].has_key[ent]:
+                raise UIError("Section %s has no entry %s"%(sec,ent))
+            return sec,ent
+        elif syn.has_key(name):
+            raise UIError("No key given for section %s"%name)
+        else:
+            secs = []
+            for secname, secitems in syn.items():
+                if secitems.has_key(name):
+                    secs.append(name)
+            if len(secs) == 0:
+                raise UIError("No key named %s found"%name)
+            elif len(secs) > 1:
+                secs = [ "%s/%s"%(name, sec) for sec in secs ]
+                raise UIError("%s is ambiguous.  Did you mean %s?",
+                              name, englishSequence(secs,compound="or"))
+            else:
+                return secs[0],name
+
+    def getFeature(self,sec,name):
+        """DOCDOC"""
+        if sec == "-":
+            return "XXXX" #XXXX006 insert magic.
+        else:
+            return self[sec].get(name,"<none>")
 
     def validate(self, entryLines, fileContents):
         """Check additional semantic properties of a set of configuration