From: W. Trevor King Date: Wed, 4 Aug 2010 12:11:17 +0000 (-0400) Subject: Expose 'conditons' config settings to plugins directly. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1a97815d42e0938fb5d2b871d674f72e88709768;p=hooke.git Expose 'conditons' config settings to plugins directly. --- diff --git a/hooke/plugin/__init__.py b/hooke/plugin/__init__.py index 8e77f2f..adaf4c1 100644 --- a/hooke/plugin/__init__.py +++ b/hooke/plugin/__init__.py @@ -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 diff --git a/hooke/plugin/tutorial.py b/hooke/plugin/tutorial.py index a126e2c..c9efa31 100644 --- a/hooke/plugin/tutorial.py +++ b/hooke/plugin/tutorial.py @@ -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'