From 4c28cccd9f96433f975b46b56ca6a24915b5e717 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 18 May 2010 08:59:16 -0400 Subject: [PATCH] Add hooke.plugin.argument_to_setting to convert Arguments -> Settings. This will make it easy for Plugins to generate Settings matching Command Arguments. --- hooke/plugin/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hooke/plugin/__init__.py b/hooke/plugin/__init__.py index 5a1d43a..dc36488 100644 --- a/hooke/plugin/__init__.py +++ b/hooke/plugin/__init__.py @@ -160,8 +160,13 @@ def load_graph(graph, config, include_section): items.append(item) return items -def setting_to_argument(self, setting): - """Convert a :class:`~hooke.conf.Setting` to an - :class:`~hooke.command.Argument`. +def argument_to_setting(self, section_name, argument): + """Convert an :class:`~hooke.command.Argument` to a + `~hooke.conf.Setting`. + + This is a lossy transition, because + :class:`~hooke.command.Argument`\s store more information than + `~hooke.conf.Setting`\s. """ - TODO + return Setting(section_name, option=argument.name, value=argument.default, + help=argument._help) -- 2.26.2