Mercurial > babel > old > mirror
changeset 163:2faa5dc63068
Slightly simplified CLI-frontend class.
author | cmlenz |
---|---|
date | Thu, 21 Jun 2007 16:12:38 +0000 |
parents | 661cb602781d |
children | 543d5626c9ef |
files | babel/messages/frontend.py babel/messages/mofile.py babel/messages/pofile.py |
diffstat | 3 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -411,8 +411,7 @@ usage = '%%prog %s [options] %s' version = '%%prog %s' % VERSION - commands = ['compile', 'extract', 'init'] - command_descriptions = { + commands = { 'compile': 'compile a message catalog to a MO file', 'extract': 'extract messages from source files and generate a POT file', 'init': 'create new message catalogs from a template' @@ -442,9 +441,10 @@ print "commands:" longest = max([len(command) for command in self.commands]) format = " %%-%ds %%s" % max(11, longest) - self.commands.sort() - for command in self.commands: - print format % (command, self.command_descriptions[command]) + commands = self.commands.items() + commands.sort() + for name, description in commands: + print format % (name, description) def compile(self, argv): """Subcommand for compiling a message catalog to a MO file. @@ -452,7 +452,7 @@ :param argv: the command arguments """ parser = OptionParser(usage=self.usage % ('init',''), - description=self.command_descriptions['init']) + description=self.commands['init']) parser.add_option('--domain', '-D', dest='domain', help="domain of MO and PO files (default '%default')") parser.add_option('--directory', '-d', dest='directory', @@ -519,7 +519,7 @@ :param argv: the command arguments """ parser = OptionParser(usage=self.usage % ('extract', 'dir1 <dir2> ...'), - description=self.command_descriptions['extract']) + description=self.commands['extract']) parser.add_option('--charset', dest='charset', help='charset to use in the output (default ' '"%default")') @@ -637,7 +637,7 @@ :param argv: the command arguments """ parser = OptionParser(usage=self.usage % ('init',''), - description=self.command_descriptions['init']) + description=self.commands['init']) parser.add_option('--domain', '-D', dest='domain', help="domain of PO file (default '%default')") parser.add_option('--input-file', '-i', dest='input_file',
--- a/babel/messages/mofile.py +++ b/babel/messages/mofile.py @@ -20,6 +20,9 @@ import array import struct +__all__ = ['write_mo'] +__docformat__ = 'restructuredtext en' + def write_mo(fileobj, catalog, use_fuzzy=False): """Write a catalog to the specified file-like object using the GNU MO file format.