[cig-commits] r6151 - in cs/pythia/trunk/pyre: applications inventory/cfg weaver/mills

leif at geodynamics.org leif at geodynamics.org
Thu Mar 1 14:24:40 PST 2007


Author: leif
Date: 2007-03-01 14:24:39 -0800 (Thu, 01 Mar 2007)
New Revision: 6151

Added:
   cs/pythia/trunk/pyre/inventory/cfg/Renderer.py
   cs/pythia/trunk/pyre/weaver/mills/ConfigMill.py
Modified:
   cs/pythia/trunk/pyre/applications/Shell.py
   cs/pythia/trunk/pyre/inventory/cfg/CodecConfig.py
Log:
Created a renderer/weaver/mill for .cfg files.  Eventually, apps will
be able to dump their configuration as a .cfg file.  (Currently,
.pml/.cfg files generated by Pyre contain garbage for any non-trivial
app, due to extant bugs from CACR.)  See issue80 for motivation.


Modified: cs/pythia/trunk/pyre/applications/Shell.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Shell.py	2007-03-01 21:23:25 UTC (rev 6150)
+++ cs/pythia/trunk/pyre/applications/Shell.py	2007-03-01 22:24:39 UTC (rev 6151)
@@ -40,14 +40,6 @@
         self.registry = None
 
 
-    def xupdateConfiguration(self, registry):
-        """divide settings between myself and the application"""
-        
-        myRegistry, yourRegistry = self.filterConfiguration(registry)
-        self.app.updateConfiguration(yourRegistry)
-        return super(Shell, self).updateConfiguration(myRegistry)
-
-
     def run(self, *args, **kwds):
 
         app = self.app

Modified: cs/pythia/trunk/pyre/inventory/cfg/CodecConfig.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/cfg/CodecConfig.py	2007-03-01 21:23:25 UTC (rev 6150)
+++ cs/pythia/trunk/pyre/inventory/cfg/CodecConfig.py	2007-03-01 22:24:39 UTC (rev 6151)
@@ -22,6 +22,10 @@
         CodecODB.__init__(self, encoding='cfg')
         return
 
+    def _createRenderer(self):
+        from Renderer import Renderer
+        return Renderer()
+
     def _decode(self, shelf):
         root = Registry("root")
         parser = Parser(root)

Added: cs/pythia/trunk/pyre/inventory/cfg/Renderer.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/cfg/Renderer.py	2007-03-01 21:23:25 UTC (rev 6150)
+++ cs/pythia/trunk/pyre/inventory/cfg/Renderer.py	2007-03-01 22:24:39 UTC (rev 6151)
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                      California Institute of Technology
+#                        (C) 2006  All Rights Reserved
+#
+# {LicenseText}
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+
+from pyre.weaver.mills.ConfigMill import ConfigMill
+
+
+class Renderer(ConfigMill):
+
+
+    def render(self, inventory):
+        document = self.weave(inventory)
+        return document
+
+
+    # handlers
+
+    def onInventory(self, inventory):
+        self._rep += ['', '# inventory', '']
+
+        for facility in inventory.facilities.itervalues():
+            facility.identify(self)
+
+        return
+
+    
+    def onRegistry(self, registry):
+
+        # bail out of empty registries
+        if not registry.properties and not registry.facilities:
+            return
+
+        self.path.append(registry.name)
+        
+        self._write('[%s]' % '.'.join(self.path))
+
+        for trait in registry.properties:
+            value = registry.getProperty(trait)
+            if trait in registry.facilities:
+                self._write('%s = %s' % (trait, value))
+            else:
+                self._write('%s = %s' % (trait, value))
+                
+        self._write('')
+        
+        for facility in registry.facilities:
+            component = registry.getFacility(facility)
+            if component:
+                component.identify(self)
+
+        self.path.pop()
+
+        return
+
+
+    def __init__(self):
+        ConfigMill.__init__(self)
+        self.path = []
+        return
+
+
+    def _renderDocument(self, document):
+        return document.identify(self)
+
+
+# end of file

Added: cs/pythia/trunk/pyre/weaver/mills/ConfigMill.py
===================================================================
--- cs/pythia/trunk/pyre/weaver/mills/ConfigMill.py	2007-03-01 21:23:25 UTC (rev 6150)
+++ cs/pythia/trunk/pyre/weaver/mills/ConfigMill.py	2007-03-01 22:24:39 UTC (rev 6151)
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                      California Institute of Technology
+#                        (C) 2006  All Rights Reserved
+#
+# {LicenseText}
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+
+from pyre.weaver.components.BlockMill import BlockMill
+
+
+class ConfigMill(BlockMill):
+
+
+    names = ["cfg"]
+
+
+    def __init__(self):
+        BlockMill.__init__(self, "#", "#", "#", '')
+        return
+
+
+# end of file



More information about the cig-commits mailing list