From 33e2c3ece373146e1890504aef0b87d87e8d57d0 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Thu, 26 Oct 2000 03:49:15 +0000 Subject: Remove bogus stdout redirection and use of sys.__stdout__; use augmented print statement instead. --- Tools/i18n/pygettext.py | 60 +++++++++++++++++++++++-------------------------- 1 file 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(): -- cgit v0.12