Add hooke.plugin.argument_to_setting to convert Arguments -> Settings.
authorW. Trevor King <wking@drexel.edu>
Tue, 18 May 2010 12:59:16 +0000 (08:59 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 18 May 2010 12:59:16 +0000 (08:59 -0400)
This will make it easy for Plugins to generate Settings matching
Command Arguments.

hooke/plugin/__init__.py

index 5a1d43abca166fc58008731289767b738b8fef0b..dc36488f2cf63e77105bd9aa71e0dcbbc42a56ad 100644 (file)
@@ -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)