/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 breezy/export_pot.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    help_topics,
39
39
    option,
40
40
    plugin as _mod_plugin,
41
 
    help,
42
41
    )
43
42
from .sixish import PY3
44
43
from .trace import (
50
49
 
51
50
def _escape(s):
52
51
    s = (s.replace('\\', '\\\\')
53
 
        .replace('\n', '\\n')
54
 
        .replace('\r', '\\r')
55
 
        .replace('\t', '\\t')
56
 
        .replace('"', '\\"')
57
 
        )
 
52
         .replace('\n', '\\n')
 
53
         .replace('\r', '\\r')
 
54
         .replace('\t', '\\t')
 
55
         .replace('"', '\\"')
 
56
         )
58
57
    return s
59
58
 
 
59
 
60
60
def _normalize(s):
61
61
    # This converts the various Python string types into a format that
62
62
    # is appropriate for .po files, namely much closer to C style.
107
107
        # TODO: fix this to do the right thing rather than rely on cwd
108
108
        relpath = os.path.relpath(sourcepath)
109
109
        return cls(relpath,
110
 
            _source_info=_parse_source("".join(inspect.findsource(module)[0]), module.__file__))
 
110
                   _source_info=_parse_source("".join(inspect.findsource(module)[0]), module.__file__))
111
111
 
112
112
    def from_class(self, cls):
113
113
        """Get new context with same details but lineno of class in source"""
117
117
            mutter("Definition of %r not found in %r", cls, self.path)
118
118
            return self
119
119
        return self.__class__(self.path, lineno,
120
 
            (self._cls_to_lineno, self._str_to_lineno))
 
120
                              (self._cls_to_lineno, self._str_to_lineno))
121
121
 
122
122
    def from_string(self, string):
123
123
        """Get new context with same details but lineno of string in source"""
127
127
            mutter("String %r not found in %r", string[:20], self.path)
128
128
            return self
129
129
        return self.__class__(self.path, lineno,
130
 
            (self._cls_to_lineno, self._str_to_lineno))
 
130
                              (self._cls_to_lineno, self._str_to_lineno))
131
131
 
132
132
 
133
133
class _PotExporter(object):
189
189
 
190
190
def _write_option(exporter, context, opt, note):
191
191
    if getattr(opt, 'hidden', False):
192
 
        return   
 
192
        return
193
193
    optname = opt.name
194
194
    if getattr(opt, 'title', None):
195
195
        exporter.poentry_in_context(context, opt.title,
196
 
            "title of {name!r} {what}".format(name=optname, what=note))
 
196
                                    "title of {name!r} {what}".format(name=optname, what=note))
197
197
    for name, _, _, helptxt in opt.iter_switches():
198
198
        if name != optname:
199
199
            if opt.is_hidden(name):
201
201
            name = "=".join([optname, name])
202
202
        if helptxt:
203
203
            exporter.poentry_in_context(context, helptxt,
204
 
                "help of {name!r} {what}".format(name=name, what=note))
 
204
                                        "help of {name!r} {what}".format(name=name, what=note))
205
205
 
206
206
 
207
207
def _standard_options(exporter):
233
233
            return True
234
234
 
235
235
    exporter.poentry_per_paragraph(dcontext.path, dcontext.lineno, doc,
236
 
        exclude_usage)
 
236
                                   exclude_usage)
237
237
    _command_options(exporter, context, cmd)
238
238
 
239
239
 
259
259
    if plugin_name is not None and plugin_name not in plugins:
260
260
        raise errors.BzrError(gettext('Plugin %s is not loaded' % plugin_name))
261
261
    core_plugins = set(
262
 
            name for name in plugins
263
 
            if plugins[name].path().startswith(breezy.__path__[0]))
 
262
        name for name in plugins
 
263
        if plugins[name].path().startswith(breezy.__path__[0]))
264
264
    # plugins
265
265
    for cmd_name in _mod_commands.plugin_command_names():
266
266
        command = _mod_commands.get_cmd_object(cmd_name, False)
275
275
            # TODO: Support extracting from third party plugins.
276
276
            continue
277
277
        note(gettext("Exporting messages from plugin command: {0} in {1}").format(
278
 
             cmd_name, command.plugin_name() ))
 
278
             cmd_name, command.plugin_name()))
279
279
        _write_command_help(exporter, command)
280
280
 
281
281
 
305
305
        doc = topic_registry.get(key)
306
306
        if isinstance(doc, str):
307
307
            exporter.poentry_per_paragraph(
308
 
                    'dummy/help_topics/'+key+'/detail.txt',
309
 
                    1, doc)
310
 
        elif callable(doc): # help topics from files
 
308
                'dummy/help_topics/' + key + '/detail.txt',
 
309
                1, doc)
 
310
        elif callable(doc):  # help topics from files
311
311
            exporter.poentry_per_paragraph(
312
 
                    'en/help_topics/'+key+'.txt',
313
 
                    1, doc(key))
 
312
                'en/help_topics/' + key + '.txt',
 
313
                1, doc(key))
314
314
        summary = topic_registry.get_summary(key)
315
315
        if summary is not None:
316
 
            exporter.poentry('dummy/help_topics/'+key+'/summary.txt',
317
 
                     1, summary)
 
316
            exporter.poentry('dummy/help_topics/' + key + '/summary.txt',
 
317
                             1, summary)
318
318
 
319
319
 
320
320
def export_pot(outf, plugin=None, include_duplicates=False):