~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/bzrgettext.py

  • Committer: INADA Naoki
  • Date: 2011-05-06 08:45:15 UTC
  • mto: (5830.3.4 i18n-msgfmt)
  • mto: This revision was merged to the branch mainline in revision 5873.
  • Revision ID: songofacandy@gmail.com-20110506084515-3h7q41pzub827rks
Export from help_topics that is directly registered into
topic_registry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
# The normalize function is taken from pygettext which is distributed
26
26
# with Python under the Python License, which is GPL compatible.
27
27
 
 
28
from __future__ import with_statement
28
29
 
29
30
"""Extract docstrings from Bazaar commands.
30
31
"""
162
163
        if fmt:
163
164
            poentry('bzrlib/erros.py', inspect.findsource(klass)[1], fmt)
164
165
 
 
166
def bzr_helptopics():
 
167
    from bzrlib.help_topics import topic_registry
 
168
    for key in topic_registry.keys():
 
169
        print >>sys.stderr, "Extracting help topic on:", key
 
170
        doc = topic_registry.get(key)
 
171
        if isinstance(doc, str):
 
172
            poentry_per_paragraph(
 
173
                    'detail of help topic about '+key,
 
174
                    0, doc)
 
175
 
 
176
        summary = topic_registry.get_summary(key)
 
177
        if summary is not None:
 
178
            poentry('summery of help topic about '+key,
 
179
                    0, summary)
 
180
 
165
181
 
166
182
def rawtext(path):
167
183
    src = open(path).read()
174
190
    # accidentally import and extract strings from a Bazaar
175
191
    # installation mentioned in PYTHONPATH.
176
192
    sys.path.insert(0, os.getcwd())
177
 
    import bzrlib.lazy_import
178
 
    for path in sys.argv[1:]:
179
 
        if path.endswith('.txt'):
180
 
            rawtext(path)
181
 
        else:
182
 
            docstrings(path)
183
 
    bzrerrors()
 
193
    import bzrlib
 
194
 
 
195
    with bzrlib.initialize():
 
196
        for path in sys.argv[1:]:
 
197
            if path.endswith('.txt'):
 
198
                rawtext(path)
 
199
            else:
 
200
                docstrings(path)
 
201
        bzrerrors()
 
202
        bzr_helptopics()