~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export_pot.py

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    errors,
29
29
    help_topics,
30
30
    plugin,
31
 
    help,
32
31
    )
33
32
from bzrlib.trace import (
34
33
    mutter,
35
34
    note,
36
35
    )
37
 
from bzrlib.i18n import gettext
38
36
 
39
37
 
40
38
def _escape(s):
78
76
           'msgid %s\n' % _normalize(s) +
79
77
           'msgstr ""\n')
80
78
 
81
 
def _poentry_per_paragraph(outf, path, lineno, msgid, filter=lambda x: False):
 
79
def _poentry_per_paragraph(outf, path, lineno, msgid):
82
80
    # TODO: How to split long help?
83
81
    paragraphs = msgid.split('\n\n')
84
82
    for p in paragraphs:
85
 
        if filter(p):
86
 
            continue
87
83
        _poentry(outf, path, lineno, p)
88
84
        lineno += p.count('\n') + 2
89
85
 
120
116
        if getattr(opt, 'title', None):
121
117
            lineno = offsets.get(opt.title, 9999)
122
118
            if lineno == 9999:
123
 
                note(gettext("%r is not found in bzrlib/option.py") % opt.title)
 
119
                note("%r is not found in bzrlib/option.py" % opt.title)
124
120
            _poentry(outf, path, lineno, opt.title,
125
121
                     'title of %r option' % name)
126
122
        if getattr(opt, 'help', None):
127
123
            lineno = offsets.get(opt.help, 9999)
128
124
            if lineno == 9999:
129
 
                note(gettext("%r is not found in bzrlib/option.py") % opt.help)
 
125
                note("%r is not found in bzrlib/option.py" % opt.help)
130
126
            _poentry(outf, path, lineno, opt.help,
131
127
                     'help of %r option' % name)
132
128
 
149
145
                     'help of %r option of %r command' % (name, cmd.name()))
150
146
 
151
147
 
152
 
def _write_command_help(outf, cmd):
 
148
def _write_command_help(outf, cmd_name, cmd):
153
149
    path = inspect.getfile(cmd.__class__)
154
150
    if path.endswith('.pyc'):
155
151
        path = path[:-1]
159
155
    lineno = offsets[cmd.__doc__]
160
156
    doc = inspect.getdoc(cmd)
161
157
 
162
 
    def filter(p):
163
 
        # ':Usage:' has special meaning in help topics.
164
 
        # This is usage example of command and should not be translated.
165
 
        if p.splitlines()[0] == ':Usage:':
166
 
            return True
167
 
 
168
 
    _poentry_per_paragraph(outf, path, lineno, doc, filter)
 
158
    _poentry_per_paragraph(outf, path, lineno, doc)
169
159
    _command_options(outf, path, cmd)
170
160
 
171
 
 
172
161
def _command_helps(outf):
173
162
    """Extract docstrings from path.
174
163
 
182
171
        command = _mod_commands.get_cmd_object(cmd_name, False)
183
172
        if command.hidden:
184
173
            continue
185
 
        note(gettext("Exporting messages from builtin command: %s"), cmd_name)
186
 
        _write_command_help(outf, command)
 
174
        note("Exporting messages from builtin command: %s", cmd_name)
 
175
        _write_command_help(outf, cmd_name, command)
187
176
 
188
177
    plugin_path = plugin.get_core_plugin_path()
189
178
    core_plugins = glob(plugin_path + '/*/__init__.py')
198
187
            # skip non-core plugins
199
188
            # TODO: Support extracting from third party plugins.
200
189
            continue
201
 
        note(gettext("Exporting messages from plugin command: {0} in {1}").format(
202
 
             cmd_name, command.plugin_name() ))
203
 
        _write_command_help(outf, command)
 
190
        note("Exporting messages from plugin command: %s in %s",
 
191
             cmd_name, command.plugin_name())
 
192
        _write_command_help(outf, cmd_name, command)
204
193
 
205
194
 
206
195
def _error_messages(outf):
223
212
            continue
224
213
        fmt = getattr(klass, "_fmt", None)
225
214
        if fmt:
226
 
            note(gettext("Exporting message from error: %s"), name)
 
215
            note("Exporting message from error: %s", name)
227
216
            _poentry(outf, 'bzrlib/errors.py',
228
217
                     offsets.get(fmt, 9999), fmt)
229
218
 
236
225
                    outf,
237
226
                    'dummy/help_topics/'+key+'/detail.txt',
238
227
                    1, doc)
239
 
        elif callable(doc): # help topics from files
240
 
            _poentry_per_paragraph(
241
 
                    outf,
242
 
                    'en/help_topics/'+key+'.txt',
243
 
                    1, doc(key))
 
228
 
244
229
        summary = topic_registry.get_summary(key)
245
230
        if summary is not None:
246
231
            _poentry(outf, 'dummy/help_topics/'+key+'/summary.txt',
252
237
    _standard_options(outf)
253
238
    _command_helps(outf)
254
239
    _error_messages(outf)
255
 
    _help_topics(outf)
 
240
    # disable exporting help topics until we decide  how to translate it.
 
241
    #_help_topics(outf)