[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8294 - trunk/gnue-common/src/apps
From: |
reinhard |
Subject: |
[gnue] r8294 - trunk/gnue-common/src/apps |
Date: |
Mon, 3 Apr 2006 18:22:41 -0500 (CDT) |
Author: reinhard
Date: 2006-03-30 14:22:00 -0600 (Thu, 30 Mar 2006)
New Revision: 8294
Modified:
trunk/gnue-common/src/apps/CommandOption.py
trunk/gnue-common/src/apps/GBaseApp.py
trunk/gnue-common/src/apps/GServerApp.py
trunk/gnue-common/src/apps/manpage.py
Log:
Switched command line help to be generally unicode.
Modified: trunk/gnue-common/src/apps/CommandOption.py
===================================================================
--- trunk/gnue-common/src/apps/CommandOption.py 2006-03-30 18:10:18 UTC (rev
8293)
+++ trunk/gnue-common/src/apps/CommandOption.py 2006-03-30 20:22:00 UTC (rev
8294)
@@ -27,6 +27,8 @@
the function addCommandOption.
"""
+from gnue.common.apps import i18n
+
class CommandOption:
def __init__(self, name, shortOption=None, longOption=None,
acceptsArgument=False, default=None, argumentName=None,
@@ -67,3 +69,8 @@
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.getencoding ())
+ if isinstance (self.argumentName, str):
+ self.argumentName = unicode (self.argumentName, i18n.getencoding ())
Modified: trunk/gnue-common/src/apps/GBaseApp.py
===================================================================
--- trunk/gnue-common/src/apps/GBaseApp.py 2006-03-30 18:10:18 UTC (rev
8293)
+++ trunk/gnue-common/src/apps/GBaseApp.py 2006-03-30 20:22:00 UTC (rev
8294)
@@ -38,7 +38,7 @@
from gnue import paths
-from gnue.common.apps import errors, GConfig, GDebug
+from gnue.common.apps import i18n, errors, GConfig, GDebug
from gnue.common.datasources import GConnections
from gnue.common.apps.CommandOption import CommandOption
@@ -117,70 +117,73 @@
## Base options
##
CommandOption ('version', category = "base", action = self.doVersion,
- help = _('Displays the version information for this program.')),
+ help = u_('Displays the version information for this program.')),
CommandOption ('debug-level', category = "base", default = 0,
- argument = _("level"),
- help = _('Enables debugging messages. Argument specifies the '
- 'level of messages to display (e.g., "--debug-level 5" '
- 'displays all debugging messages at level 5 or below.)')),
+ argument = u_("level"),
+ help = u_('Enables debugging messages. Argument specifies the '
+ 'level of messages to display (e.g., "--debug-level 5" '
+ 'displays all debugging messages at level 5 or below.)')),
- CommandOption ('debug-file', category = "base", argument = _("filename"),
- help = _('Sends all debugging messages to a specified file '
- '(e.g., "--debug-file trace.log" sends all output to '
- '"trace.log")')),
+ CommandOption ('debug-file', category = "base", argument =
u_("filename"),
+ help = u_('Sends all debugging messages to a specified file '
+ '(e.g., "--debug-file trace.log" sends all output to '
+ '"trace.log")')),
# This is actually handled during the initial GDebug import but is added
# here so that applications won't abort with an unknown option.
CommandOption ('debug-imports', category = "dev",
- help = _('All python imports are logged to stdout')),
+ help = u_('All python imports are logged to stdout')),
CommandOption ('silent', category = "base",
- help = _('Displays no output at all.')),
+ help = u_('Displays no output at all.')),
CommandOption ('help', category = "base", action = self.printHelp,
- help = _('Displays this help screen.')),
+ help = u_('Displays this help screen.')),
CommandOption ('help-config', category = "base",
action = self.doHelpConfig,
- help = _('Displays a list of valid configuration file entries, their '
- 'purpose, and their default values.')),
+ help = u_('Displays a list of valid configuration file entries, their '
+ 'purpose, and their default values.')),
##
## Developer options
##
CommandOption ('help-dev', category = "base", action = self.printHelpDev,
- help = _('Display all options of interest to core developers. ')),
+ help = u_('Display all options of interest to core developers. ')),
CommandOption ('selfdoc', category = "dev", action = self.doSelfDoc,
- argument = _("type[,subtype]"),
- help = _('Generates self-documentation.')),
+ argument = u_("type[,subtype]"),
+ help = u_('Generates self-documentation.')),
- CommandOption ('selfdoc-format', category = "dev", argument =
_("format"),
- help = _('Format to output the self-documentation in. Supported '
- 'formats are dependent on the type of selfdoc being '
- 'created.')),
+ CommandOption ('selfdoc-format', category = "dev",
+ argument = u_("format"),
+ help = u_('Format to output the self-documentation in. Supported '
+ 'formats are dependent on the type of selfdoc being '
+ 'created.')),
- CommandOption ('selfdoc-file', category = "dev", argument =
_("filename"),
- help = _('Specifies the filename that selfdoc should write to. If not '
- 'provided, output is sent to stdout.')),
+ CommandOption ('selfdoc-file', category = "dev",
+ argument = u_("filename"),
+ help = u_('Specifies the filename that selfdoc should write to. If not
'
+ 'provided, output is sent to stdout.')),
CommandOption ('selfdoc-options', category = "dev",
- argument = _("options"),
- help = _('Options specific to individual selfdoc types.')),
+ argument = u_("options"),
+ help = u_('Options specific to individual selfdoc types.')),
CommandOption ('profile', category = "dev",
- help = _("Run Python's built-in profiler and display the resulting "
- "run statistics.")),
+ help = u_("Run Python's built-in profiler and display the resulting "
+ "run statistics.")),
CommandOption ('interactive-debugger', category = "dev",
- help = _("Run the app inside Python's built-in debugger ")),
+ help = u_("Run the app inside Python's built-in debugger ")),
CommandOption ('debug-gc', 'g', 'debug-gc', True, None, "logfile",
category = "dev", action = self.__installGCHandler,
- help = _("Debug Python's garbage collection on a SIGUSR1. If the "
- "argument is empty 'garbage.log' will be used as
logfile.")),
+ help = u_("Debug Python's garbage collection on a SIGUSR1. If the "
+ "argument is empty 'garbage.log' will be used as "
+ "logfile.")),
#CommandOption ('garbagelog', 'l'
]
@@ -189,36 +192,36 @@
self.USE_CONNECTIONS = 1
self._base_options.extend ([ \
CommandOption ('username', category = "connections", default = '',
- argument = 'name',
- help = _('Username used to log into the database. Note that if '
- 'specified, this will be used for all databases. If not '
- 'supplied, the program will prompt for username.')),
+ argument = u_('name'),
+ help = u_('Username used to log into the database. Note that if '
+ 'specified, this will be used for all databases. If not '
+ 'supplied, the program will prompt for username.')),
CommandOption ('password', category = "connections", default = '',
- argument = 'passwd',
- help = _('Password used to log into the database. Note that if '
- 'specified, this will be used for all databases. If not '
- 'supplied, the program will prompt for password if needed.'
- '\nNOTE: SUPPLYING A PASSWORD VIA THE COMMAND LINE MAY BE '
- 'CONSIDERED A SECURITY RISK AND IS NOT RECOMMENDED.'))])
+ argument = u_('passwd'),
+ help = u_('Password used to log into the database. Note that if '
+ 'specified, this will be used for all databases. If not '
+ 'supplied, the program will prompt for password if needed.'
+ '\nNOTE: SUPPLYING A PASSWORD VIA THE COMMAND LINE MAY BE '
+ 'CONSIDERED A SECURITY RISK AND IS NOT RECOMMENDED.'))])
if self.USE_CONNECTIONS:
self._base_options += [
CommandOption ('help-connections', category = "base",
action = self.printHelpConn,
- help = _('Display help information related to database '
- 'connections, including a list of available drivers.')),
+ help = u_('Display help information related to database '
+ 'connections, including a list of available drivers.')),
CommandOption ('connections', category = "connections",
- argument = "loc",
- help = _('Specifies the location of the connection definition file. '
- '<loc> may specify a file name '
- '(/usr/local/gnue/etc/connections.conf),'
- 'or a URL location '
- '(http://localhost/connections.conf).'
- 'If this option is not specified, the environent variable '
- 'GNUE_CONNECTIONS is checked.'
- 'If neither of them is set, "%s" is used as a default.') %
+ argument = u_("location"),
+ help = u_('Specifies the location of the connection definition file.
'
+ '<location> may specify a file name '
+ '(/usr/local/gnue/etc/connections.conf),'
+ 'or a URL location '
+ '(http://localhost/connections.conf).'
+ 'If this option is not specified, the environent variable '
+ 'GNUE_CONNECTIONS is checked.'
+ 'If neither of them is set, "%s" is used as a default.') %
os.path.join (paths.config, "connections.conf")) ]
# Python version check
@@ -480,7 +483,7 @@
sorted = allOptions.keys ()
sorted.sort ()
- dispOptions = ""
+ dispOptions = u""
for optionKey in sorted:
margin = maxLength + 4
@@ -517,7 +520,7 @@
"""
self.printVersion ()
- print _("Usage: ") + self.COMMAND + ' ' + self.USAGE
+ print o(u_("Usage: ") + self.COMMAND + ' ' + self.USAGE)
print
@@ -531,7 +534,7 @@
"""
print
- print "%s\n" % self.REPORT_BUGS_TO
+ print o("%s\n" % self.REPORT_BUGS_TO)
# ---------------------------------------------------------------------------
@@ -546,10 +549,10 @@
"""
self.printHelpHeader ()
- print "\n" + self.SUMMARY + '\n'
+ print o("\n" + self.SUMMARY + '\n')
- print _('Available command line options:')
- print self.buildHelpOptions ()
+ print o(u_('Available command line options:'))
+ print o(self.buildHelpOptions ())
self.printHelpFooter ()
sys.exit ()
@@ -567,11 +570,13 @@
self.printHelpHeader ()
- print _("The following options are mainly of interest to GNUe developers.")
- print _("To view general help, run this command with the --help option.")
+ print o(u_("The following options are mainly of interest to GNUe "
+ "developers."))
+ print o(u_("To view general help, run this command with the --help "
+ "option."))
print
- print _('Developer-specific command line options:')
- print self.buildHelpOptions ("dev")
+ print o(u_('Developer-specific command line options:'))
+ print o(self.buildHelpOptions ("dev"))
self.printHelpFooter ()
sys.exit ()
@@ -588,13 +593,15 @@
self.printHelpHeader ()
- print _("The following connection/database-related options are available.")
- print _("To view general help, run this command with the --help option.")
+ print o(u_("The following connection/database-related options are "
+ "available."))
+ print o(u_("To view general help, run this command with the --help "
+ "option."))
print
- print _('Database/connection command line options:')
- print self.buildHelpOptions ("connections")
+ print o(u_('Database/connection command line options:'))
+ print o(self.buildHelpOptions ("connections"))
print
- print _('The following database drivers are installed on your system:')
+ print o(u_('The following database drivers are installed on your system:'))
print " TODO\n"
# print self.connections.getAvailableDrivers()
self.printHelpFooter ()
@@ -716,7 +723,7 @@
self.OPTIONS ['selfdoc-options'])
if doprint:
handle.seek (0)
- print handle.read ()
+ print o(handle.read ())
finally:
handle.close ()
@@ -735,7 +742,7 @@
"""
self.printHelpHeader ()
- print GConfig.printableConfigOptions (self.configDefaults)
+ print o(GConfig.printableConfigOptions (self.configDefaults))
sys.exit ()
@@ -888,7 +895,7 @@
def __gcLog (self, filehandle, message):
filehandle.write ("%s%s" % (message, os.linesep))
- print message
+ print o(message)
# ---------------------------------------------------------------------------
Modified: trunk/gnue-common/src/apps/GServerApp.py
===================================================================
--- trunk/gnue-common/src/apps/GServerApp.py 2006-03-30 18:10:18 UTC (rev
8293)
+++ trunk/gnue-common/src/apps/GServerApp.py 2006-03-30 20:22:00 UTC (rev
8294)
@@ -45,23 +45,21 @@
errors.UserError.__init__ (self, msg)
-# TODO: Implement either multi-threading or asynchronous IO support
-
class GServerApp(GBaseApp):
def __init__(self, connections=None, application=None, defaults=None):
self.COMMAND_OPTIONS.append (
[ 'foreground','Z','no-detach',0,0, None,
- _("Do not send the server into the background. For a POSIX system, "
+ u_("Do not send the server into the background. For a POSIX system, "
"this option keeps the server process from forking and detaching "
"from its controlling terminal.")],
)
self.COMMAND_OPTIONS.append (
['pidfile', 'P', 'pidfile', True,
- '/var/run/gnue/%s.pid' % application or 'gnue', 'pid-file',
- _("Filename to store the server's process id.")])
+ '/var/run/gnue/%s.pid' % application or 'gnue', u_('pid-file'),
+ u_("Filename to store the server's process id.")])
GBaseApp.__init__(self, connections, application, defaults)
Modified: trunk/gnue-common/src/apps/manpage.py
===================================================================
--- trunk/gnue-common/src/apps/manpage.py 2006-03-30 18:10:18 UTC (rev
8293)
+++ trunk/gnue-common/src/apps/manpage.py 2006-03-30 20:22:00 UTC (rev
8294)
@@ -127,7 +127,7 @@
allOptions[string.upper(option.longOption)] = option
if option.acceptsArgument:
- descr = '.B \-\-%s <%s>' % (option.longOption, option.argumentName
or _("value"))
+ descr = '.B \-\-%s <%s>' % (option.longOption, option.argumentName
or u_("value"))
else:
descr = '.B \-\-%s' % (option.longOption)
if option.shortOption:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8294 - trunk/gnue-common/src/apps,
reinhard <=