From: W. Trevor King Date: Tue, 18 May 2010 12:59:16 +0000 (-0400) Subject: Add hooke.plugin.argument_to_setting to convert Arguments -> Settings. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4c28cccd9f96433f975b46b56ca6a24915b5e717;p=hooke.git Add hooke.plugin.argument_to_setting to convert Arguments -> Settings. This will make it easy for Plugins to generate Settings matching Command Arguments. --- 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)