Expose 'conditons' config settings to plugins directly.
authorW. Trevor King <wking@drexel.edu>
Wed, 4 Aug 2010 12:11:17 +0000 (08:11 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 4 Aug 2010 12:11:17 +0000 (08:11 -0400)
hooke/plugin/__init__.py
hooke/plugin/tutorial.py

index 8e77f2fd90f834c1d49fec30aaf7e471acbd5139..adaf4c1ae948ec402407f6c0e5eb5578a78c7831 100644 (file)
@@ -170,6 +170,7 @@ def default_settings():
 def load_graph(graph, config, include_section):
     enabled = {}
     items = []
+    conditions = config.items('conditions')
     for node in graph:
         item = node.data
         try:
@@ -189,6 +190,9 @@ def load_graph(graph, config, include_section):
             try:
                 item.config = dict(config.items(item.setting_section))
             except configparser.NoSectionError:
-                pass
+                item.config = {}
+            for key,value in conditions:
+                if key not in item.config:
+                    item.config[key] = value
             items.append(item)
     return items
index a126e2cca36a6577fc43a936c041ef0c3097ba7e..c9efa31569b5bea428c5146be314b9224aed3401 100644 (file)
@@ -220,6 +220,8 @@ class HookeInfoCommand (Command):
         hooke.config.write(config_file)
         outqueue.put('configuration:\n  %s'
                      % '\n  '.join(config_file.getvalue().splitlines()))
+        # The plugin's configuration settings are also available.
+        outqueue.put('plugin config: %s' % self.plugin.config)
         # hooke.plugins contains :class:`hooke.plugin.Plugin`\s defining
         # :class:`hooke.command.Command`\s.
         outqueue.put('plugins: %s'