@@ -283,38 +283,34 @@ def write(self, fp):
283283 options = self .__options
284284 timestamp = time .ctime (time .time ())
285285 # common header
286- try :
287- sys .stdout = fp
288- # The time stamp in the header doesn't have the same format
289- # as that generated by xgettext...
290- print pot_header % {'time' : timestamp , 'version' : __version__ }
291- for k , v in self .__messages .items ():
292- if not options .writelocations :
293- pass
294- # location comments are different b/w Solaris and GNU:
295- elif options .locationstyle == options .SOLARIS :
296- for filename , lineno in v :
297- d = {'filename' : filename , 'lineno' : lineno }
298- print _ ('# File: %(filename)s, line: %(lineno)d' ) % d
299- elif options .locationstyle == options .GNU :
300- # fit as many locations on one line, as long as the
301- # resulting line length doesn't exceeds 'options.width'
302- locline = '#:'
303- for filename , lineno in v :
304- d = {'filename' : filename , 'lineno' : lineno }
305- s = _ (' %(filename)s:%(lineno)d' ) % d
306- if len (locline ) + len (s ) <= options .width :
307- locline = locline + s
308- else :
309- print locline
310- locline = "#:" + s
311- if len (locline ) > 2 :
312- print locline
313- # TBD: sorting, normalizing
314- print 'msgid' , normalize (k )
315- print 'msgstr ""\n '
316- finally :
317- sys .stdout = sys .__stdout__
286+ # The time stamp in the header doesn't have the same format
287+ # as that generated by xgettext...
288+ print >> fp , pot_header % {'time' : timestamp , 'version' : __version__ }
289+ for k , v in self .__messages .items ():
290+ if not options .writelocations :
291+ pass
292+ # location comments are different b/w Solaris and GNU:
293+ elif options .locationstyle == options .SOLARIS :
294+ for filename , lineno in v :
295+ d = {'filename' : filename , 'lineno' : lineno }
296+ print >> fp , _ ('# File: %(filename)s, line: %(lineno)d' ) % d
297+ elif options .locationstyle == options .GNU :
298+ # fit as many locations on one line, as long as the
299+ # resulting line length doesn't exceeds 'options.width'
300+ locline = '#:'
301+ for filename , lineno in v :
302+ d = {'filename' : filename , 'lineno' : lineno }
303+ s = _ (' %(filename)s:%(lineno)d' ) % d
304+ if len (locline ) + len (s ) <= options .width :
305+ locline = locline + s
306+ else :
307+ print >> fp , locline
308+ locline = "#:" + s
309+ if len (locline ) > 2 :
310+ print >> fp , locline
311+ # TBD: sorting, normalizing
312+ print >> fp , 'msgid' , normalize (k )
313+ print >> fp , 'msgstr ""\n '
318314
319315
320316def main ():
0 commit comments