From 889a06ff524459996aac55bdce6595450b03ed7a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 4 Aug 2010 08:11:17 -0400 Subject: [PATCH] Expose 'conditons' config settings to plugins directly. --- hooke/plugin/__init__.py | 6 +++++- hooke/plugin/tutorial.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) 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' -- 2.26.2