diff options
author | Fred Drake <fdrake@acm.org> | 2000-10-26 03:49:15 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-10-26 03:49:15 (GMT) |
commit | 33e2c3ece373146e1890504aef0b87d87e8d57d0 (patch) | |
tree | b504bf30aab7f3590eae01e0f78b7b57a595dba7 | |
parent | bce920129c41397928f4e7e0001a7c967379d879 (diff) | |
download | cpython-33e2c3ece373146e1890504aef0b87d87e8d57d0.zip cpython-33e2c3ece373146e1890504aef0b87d87e8d57d0.tar.gz cpython-33e2c3ece373146e1890504aef0b87d87e8d57d0.tar.bz2 |
Remove bogus stdout redirection and use of sys.__stdout__; use
augmented print statement instead.
-rwxr-xr-x | Tools/i18n/pygettext.py | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py index 546874c..f48ee78 100755 --- a/Tools/i18n/pygettext.py +++ b/Tools/i18n/pygettext.py @@ -283,38 +283,34 @@ class TokenEater: options = self.__options timestamp = time.ctime(time.time()) # common header - try: - sys.stdout = fp - # The time stamp in the header doesn't have the same format - # as that generated by xgettext... - print pot_header % {'time': timestamp, 'version': __version__} - for k, v in self.__messages.items(): - if not options.writelocations: - pass - # location comments are different b/w Solaris and GNU: - elif options.locationstyle == options.SOLARIS: - for filename, lineno in v: - d = {'filename': filename, 'lineno': lineno} - print _('# File: %(filename)s, line: %(lineno)d') % d - elif options.locationstyle == options.GNU: - # fit as many locations on one line, as long as the - # resulting line length doesn't exceeds 'options.width' - locline = '#:' - for filename, lineno in v: - d = {'filename': filename, 'lineno': lineno} - s = _(' %(filename)s:%(lineno)d') % d - if len(locline) + len(s) <= options.width: - locline = locline + s - else: - print locline - locline = "#:" + s - if len(locline) > 2: - print locline - # TBD: sorting, normalizing - print 'msgid', normalize(k) - print 'msgstr ""\n' - finally: - sys.stdout = sys.__stdout__ + # The time stamp in the header doesn't have the same format + # as that generated by xgettext... + print >>fp, pot_header % {'time': timestamp, 'version': __version__} + for k, v in self.__messages.items(): + if not options.writelocations: + pass + # location comments are different b/w Solaris and GNU: + elif options.locationstyle == options.SOLARIS: + for filename, lineno in v: + d = {'filename': filename, 'lineno': lineno} + print >>fp, _('# File: %(filename)s, line: %(lineno)d') % d + elif options.locationstyle == options.GNU: + # fit as many locations on one line, as long as the + # resulting line length doesn't exceeds 'options.width' + locline = '#:' + for filename, lineno in v: + d = {'filename': filename, 'lineno': lineno} + s = _(' %(filename)s:%(lineno)d') % d + if len(locline) + len(s) <= options.width: + locline = locline + s + else: + print >>fp, locline + locline = "#:" + s + if len(locline) > 2: + print >>fp, locline + # TBD: sorting, normalizing + print >>fp, 'msgid', normalize(k) + print >>fp, 'msgstr ""\n' def main(): |