[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9813 - trunk/gnue-common/src/apps
From: |
johannes |
Subject: |
[gnue] r9813 - trunk/gnue-common/src/apps |
Date: |
Fri, 16 Nov 2007 01:23:22 -0600 (CST) |
Author: johannes
Date: 2007-11-16 01:23:20 -0600 (Fri, 16 Nov 2007)
New Revision: 9813
Modified:
trunk/gnue-common/src/apps/CommandOption.py
Log:
PEP8-ification
Modified: trunk/gnue-common/src/apps/CommandOption.py
===================================================================
--- trunk/gnue-common/src/apps/CommandOption.py 2007-11-15 09:39:57 UTC (rev
9812)
+++ trunk/gnue-common/src/apps/CommandOption.py 2007-11-16 07:23:20 UTC (rev
9813)
@@ -1,6 +1,9 @@
+# GNU Enterprise Common Library - Application Services - Command line options
#
-# This file is part of GNU Enterprise.
+# Copyright 2001-2007 Free Software Foundation
#
+# This file is part of GNU Enterprise
+#
# GNU Enterprise is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
@@ -16,61 +19,67 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2007 Free Software Foundation
-#
-# FILE:
-# CommandOption.py
-#
-# DESCRIPTION:
+# $Id$
"""
-Command option available to GBaseApp and descendants. Usualy asigned with
+Command option available to GBaseApp and descendants. Usualy asigned with
the function addCommandOption.
"""
-from gnue.common.apps import i18n
+from gnue.common.base import i18n
+__all__ = ['CommandOption']
+
+# =============================================================================
+# Class representing a command line option
+# =============================================================================
+
class CommandOption:
- def __init__(self, name, shortOption=None, longOption=None,
- acceptsArgument=False, default=None, argumentName=None,
- help="", category="general", action=None, argument=None):
- """
- @param name: The key name that will be avaliable in the self.OPTION
- dictionary when the application is executing.
- @param shortOption: Single letter to be assignd to this option.
- @param longOption: The long option name that is prepended with -- on the
- command line.
- @param acceptsArgument: True if the option requires a value to be
- assigned from the command line.
- @param default: Default value if the option is not passed in via the
- command line.
- @param argumentName: Same as argument, overridden by argument.
- @param help: Description of the option as displayed in help text.
- @param category: Used to create groups of command options, where groups
- "base", "dev", "connections" and "general" are predefined. There is
- an option --help-dev, --help-connections to give a special help-text
- for these groups of options.
- @param action: Function-pointer; if supplied this function will be called
- automatically if the option is given on command line.
- @param argument: Option argument as shown in help text. Same as
- argumentName.
- """
- self.name = name
- self.shortOption = shortOption
- self.longOption = longOption or name.replace('_','-')
- self.default = default
- self.help = help
- self.category = category
- self.action = action
- if argument:
- self.acceptsArgument=True
- self.argumentName = argument
- else:
- self.acceptsArgument=acceptsArgument
- self.argumentName = argumentName
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
- # FIXME: only for compatibility, remove in some later version!
- if isinstance (self.help, str):
- self.help = unicode (self.help, i18n.getencoding ())
- if isinstance (self.argumentName, str):
- self.argumentName = unicode (self.argumentName, i18n.getencoding ())
+ def __init__(self, name, shortOption=None, longOption=None,
+ acceptsArgument=False, default=None, argumentName=None,
+ help="", category="general", action=None, argument=None):
+ """
+ @param name: The key name that will be avaliable in the self.OPTION
+ dictionary when the application is executing.
+ @param shortOption: Single letter to be assignd to this option.
+ @param longOption: The long option name that is prepended with -- on
+ the command line.
+ @param acceptsArgument: True if the option requires a value to be
+ assigned from the command line.
+ @param default: Default value if the option is not passed in via the
+ command line.
+ @param argumentName: Same as argument, overridden by argument.
+ @param help: Description of the option as displayed in help text.
+ @param category: Used to create groups of command options, where groups
+ "base", "dev", "connections" and "general" are predefined. There is
+ an option --help-dev, --help-connections to give a special
+ help-text for these groups of options.
+ @param action: Function-pointer; if supplied this function will be
+ called automatically if the option is given on command line.
+ @param argument: Option argument as shown in help text. Same as
+ argumentName.
+ """
+ self.name = name
+ self.shortOption = shortOption
+ self.longOption = longOption or name.replace('_','-')
+ self.default = default
+ self.help = help
+ self.category = category
+ self.action = action
+
+ if argument:
+ self.acceptsArgument = True
+ self.argumentName = argument
+ else:
+ self.acceptsArgument = acceptsArgument
+ self.argumentName = argumentName
+
+ # FIXME: only for compatibility, remove in some later version!
+ if isinstance (self.help, str):
+ self.help = unicode (self.help, i18n.get_encoding())
+ if isinstance (self.argumentName, str):
+ self.argumentName = unicode (self.argumentName,
i18n.get_encoding())
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9813 - trunk/gnue-common/src/apps,
johannes <=