/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/export_pot.py

Add test for exporting command help.
It checks ":Usage:" is not exported.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
           'msgid %s\n' % _normalize(s) +
77
77
           'msgstr ""\n')
78
78
 
79
 
def _poentry_per_paragraph(outf, path, lineno, msgid):
 
79
def _poentry_per_paragraph(outf, path, lineno, msgid, filter=lambda x: False):
80
80
    # TODO: How to split long help?
81
81
    paragraphs = msgid.split('\n\n')
82
82
    for p in paragraphs:
83
 
        if p.splitlines()[0] == ':Usage:':
84
 
            # :Usage: has special meaning in help topics.
85
 
            # This is usage example of command and should not be translated.
 
83
        if filter(p):
86
84
            continue
87
85
        _poentry(outf, path, lineno, p)
88
86
        lineno += p.count('\n') + 2
149
147
                     'help of %r option of %r command' % (name, cmd.name()))
150
148
 
151
149
 
152
 
def _write_command_help(outf, cmd_name, cmd):
 
150
def _write_command_help(outf, cmd):
153
151
    path = inspect.getfile(cmd.__class__)
154
152
    if path.endswith('.pyc'):
155
153
        path = path[:-1]
159
157
    lineno = offsets[cmd.__doc__]
160
158
    doc = inspect.getdoc(cmd)
161
159
 
162
 
    _poentry_per_paragraph(outf, path, lineno, doc)
 
160
    def filter(p):
 
161
        # ':Usage:' has special meaning in help topics.
 
162
        # This is usage example of command and should not be translated.
 
163
        if p.splitlines()[0] == ':Usage:':
 
164
            return True
 
165
 
 
166
    _poentry_per_paragraph(outf, path, lineno, doc, filter)
163
167
    _command_options(outf, path, cmd)
164
168
 
 
169
 
165
170
def _command_helps(outf):
166
171
    """Extract docstrings from path.
167
172
 
176
181
        if command.hidden:
177
182
            continue
178
183
        note("Exporting messages from builtin command: %s", cmd_name)
179
 
        _write_command_help(outf, cmd_name, command)
 
184
        _write_command_help(outf, command)
180
185
 
181
186
    plugin_path = plugin.get_core_plugin_path()
182
187
    core_plugins = glob(plugin_path + '/*/__init__.py')
193
198
            continue
194
199
        note("Exporting messages from plugin command: %s in %s",
195
200
             cmd_name, command.plugin_name())
196
 
        _write_command_help(outf, cmd_name, command)
 
201
        _write_command_help(outf, command)
197
202
 
198
203
 
199
204
def _error_messages(outf):