/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

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