/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

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
"""Extract docstrings from Bazaar commands.
21
21
 
22
 
This module only handles breezy objects that use strings not directly wrapped
 
22
This module only handles bzrlib objects that use strings not directly wrapped
23
23
by a gettext() call. To generate a complete translation template file, this
24
24
output needs to be combined with that of xgettext or a similar command for
25
25
extracting those strings, as is done in the bzr Makefile. Sorting the output
31
31
import inspect
32
32
import os
33
33
 
34
 
import breezy
35
 
from . import (
 
34
from bzrlib import (
36
35
    commands as _mod_commands,
37
36
    errors,
38
37
    help_topics,
39
38
    option,
40
 
    plugin as _mod_plugin,
 
39
    plugin,
41
40
    help,
42
41
    )
43
 
from .trace import (
 
42
from bzrlib.trace import (
44
43
    mutter,
45
44
    note,
46
45
    )
47
 
from .i18n import gettext
 
46
from bzrlib.i18n import gettext
48
47
 
49
48
 
50
49
def _escape(s):
66
65
        if not lines[-1]:
67
66
            del lines[-1]
68
67
            lines[-1] = lines[-1] + '\n'
 
68
        lines = map(_escape, lines)
69
69
        lineterm = '\\n"\n"'
70
 
        s = '""\n"' + lineterm.join(map(_escape, lines)) + '"'
 
70
        s = '""\n"' + lineterm.join(lines) + '"'
71
71
    return s
72
72
 
73
73
 
203
203
def _standard_options(exporter):
204
204
    OPTIONS = option.Option.OPTIONS
205
205
    context = exporter.get_context(option)
206
 
    for name in sorted(OPTIONS):
 
206
    for name in sorted(OPTIONS.keys()):
207
207
        opt = OPTIONS[name]
208
208
        _write_option(exporter, context.from_string(name), opt, "option")
209
209
 
239
239
    This respects the Bazaar cmdtable/table convention and will
240
240
    only extract docstrings from functions mentioned in these tables.
241
241
    """
 
242
    from glob import glob
242
243
 
243
244
    # builtin commands
244
245
    for cmd_name in _mod_commands.builtin_command_names():
251
252
        note(gettext("Exporting messages from builtin command: %s"), cmd_name)
252
253
        _write_command_help(exporter, command)
253
254
 
254
 
    plugins = _mod_plugin.plugins()
255
 
    if plugin_name is not None and plugin_name not in plugins:
256
 
        raise errors.BzrError(gettext('Plugin %s is not loaded' % plugin_name))
257
 
    core_plugins = set(
258
 
            name for name in plugins
259
 
            if plugins[name].path().startswith(breezy.__path__[0]))
 
255
    plugin_path = plugin.get_core_plugin_path()
 
256
    core_plugins = glob(plugin_path + '/*/__init__.py')
 
257
    core_plugins = [os.path.basename(os.path.dirname(p))
 
258
                        for p in core_plugins]
260
259
    # plugins
261
260
    for cmd_name in _mod_commands.plugin_command_names():
262
261
        command = _mod_commands.get_cmd_object(cmd_name, False)
263
262
        if command.hidden:
264
263
            continue
265
264
        if plugin_name is not None and command.plugin_name() != plugin_name:
266
 
            # if we are exporting plugin commands, skip plugins we have not
267
 
            # specified.
 
265
            # if we are exporting plugin commands, skip plugins we have not specified.
268
266
            continue
269
267
        if plugin_name is None and command.plugin_name() not in core_plugins:
270
268
            # skip non-core plugins
276
274
 
277
275
 
278
276
def _error_messages(exporter):
279
 
    """Extract fmt string from breezy.errors."""
 
277
    """Extract fmt string from bzrlib.errors."""
280
278
    context = exporter.get_context(errors)
281
279
    base_klass = errors.BzrError
282
280
    for name in dir(errors):