mirror of
https://github.com/python/cpython.git
synced 2025-11-13 07:26:31 +00:00
Remove bogus stdout redirection and use of sys.__stdout__; use
augmented print statement instead.
This commit is contained in:
parent
bce920129c
commit
33e2c3ece3
1 changed files with 28 additions and 32 deletions
|
|
@ -283,38 +283,34 @@ class TokenEater:
|
||||||
options = self.__options
|
options = self.__options
|
||||||
timestamp = time.ctime(time.time())
|
timestamp = time.ctime(time.time())
|
||||||
# common header
|
# common header
|
||||||
try:
|
# The time stamp in the header doesn't have the same format
|
||||||
sys.stdout = fp
|
# as that generated by xgettext...
|
||||||
# The time stamp in the header doesn't have the same format
|
print >>fp, pot_header % {'time': timestamp, 'version': __version__}
|
||||||
# as that generated by xgettext...
|
for k, v in self.__messages.items():
|
||||||
print pot_header % {'time': timestamp, 'version': __version__}
|
if not options.writelocations:
|
||||||
for k, v in self.__messages.items():
|
pass
|
||||||
if not options.writelocations:
|
# location comments are different b/w Solaris and GNU:
|
||||||
pass
|
elif options.locationstyle == options.SOLARIS:
|
||||||
# location comments are different b/w Solaris and GNU:
|
for filename, lineno in v:
|
||||||
elif options.locationstyle == options.SOLARIS:
|
d = {'filename': filename, 'lineno': lineno}
|
||||||
for filename, lineno in v:
|
print >>fp, _('# File: %(filename)s, line: %(lineno)d') % d
|
||||||
d = {'filename': filename, 'lineno': lineno}
|
elif options.locationstyle == options.GNU:
|
||||||
print _('# File: %(filename)s, line: %(lineno)d') % d
|
# fit as many locations on one line, as long as the
|
||||||
elif options.locationstyle == options.GNU:
|
# resulting line length doesn't exceeds 'options.width'
|
||||||
# fit as many locations on one line, as long as the
|
locline = '#:'
|
||||||
# resulting line length doesn't exceeds 'options.width'
|
for filename, lineno in v:
|
||||||
locline = '#:'
|
d = {'filename': filename, 'lineno': lineno}
|
||||||
for filename, lineno in v:
|
s = _(' %(filename)s:%(lineno)d') % d
|
||||||
d = {'filename': filename, 'lineno': lineno}
|
if len(locline) + len(s) <= options.width:
|
||||||
s = _(' %(filename)s:%(lineno)d') % d
|
locline = locline + s
|
||||||
if len(locline) + len(s) <= options.width:
|
else:
|
||||||
locline = locline + s
|
print >>fp, locline
|
||||||
else:
|
locline = "#:" + s
|
||||||
print locline
|
if len(locline) > 2:
|
||||||
locline = "#:" + s
|
print >>fp, locline
|
||||||
if len(locline) > 2:
|
# TBD: sorting, normalizing
|
||||||
print locline
|
print >>fp, 'msgid', normalize(k)
|
||||||
# TBD: sorting, normalizing
|
print >>fp, 'msgstr ""\n'
|
||||||
print 'msgid', normalize(k)
|
|
||||||
print 'msgstr ""\n'
|
|
||||||
finally:
|
|
||||||
sys.stdout = sys.__stdout__
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue