[Python-checkins] CVS: python/dist/src/Tools/i18n pygettext.py,1.13,1.14

Barry Warsaw bwarsaw@users.sourceforge.net
Mon, 21 May 2001 12:35:22 -0700


Update of /cvsroot/python/python/dist/src/Tools/i18n
In directory usw-pr-cvs1:/tmp/cvs-serv26089

Modified Files:
	pygettext.py 
Log Message:
write(): A patch inspired by Tokio Kikuchi that sorts location entries
first by filename and then by line number.  Closes SF patch #425821.

Also, fixes a problem with duplicate entries.


Index: pygettext.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/i18n/pygettext.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** pygettext.py	2001/03/01 22:56:17	1.13
--- pygettext.py	2001/05/21 19:35:20	1.14
***************
*** 1,6 ****
  #! /usr/bin/env python
! # Originally written by Barry Warsaw <bwarsaw@python.org>
  #
! # minimally patched to make it even more xgettext compatible 
  # by Peter Funk <pf@artcom-gmbh.de>
  
--- 1,6 ----
  #! /usr/bin/env python
! # Originally written by Barry Warsaw <barry@digicool.com>
  #
! # Minimally patched to make it even more xgettext compatible 
  # by Peter Funk <pf@artcom-gmbh.de>
  
***************
*** 314,318 ****
          if not msg in self.__options.toexclude:
              entry = (self.__curfile, lineno)
!             self.__messages.setdefault(msg, []).append(entry)
  
      def set_filename(self, filename):
--- 314,318 ----
          if not msg in self.__options.toexclude:
              entry = (self.__curfile, lineno)
!             self.__messages.setdefault(msg, {})[entry] = 1
  
      def set_filename(self, filename):
***************
*** 326,329 ****
--- 326,334 ----
          print >> fp, pot_header % {'time': timestamp, 'version': __version__}
          for k, v in self.__messages.items():
+             # k is the message string, v is a dictionary-set of (filename,
+             # lineno) tuples.  We want to sort the entries in v first by file
+             # name and then by line number.
+             v = v.keys()
+             v.sort()
              if not options.writelocations:
                  pass
***************
*** 445,450 ****
              fp.close()
          except IOError:
!             sys.stderr.write(_("Can't read --exclude-file: %s") %
!                              options.excludefilename)
              sys.exit(1)
      else:
--- 450,455 ----
              fp.close()
          except IOError:
!             print >> sys.stderr, _(
!                 "Can't read --exclude-file: %s") % options.excludefilename
              sys.exit(1)
      else:
***************
*** 469,474 ****
                  tokenize.tokenize(fp.readline, eater)
              except tokenize.TokenError, e:
!                 sys.stderr.write('%s: %s, line %d, column %d\n' %
!                                  (e[0], filename, e[1][0], e[1][1]))
          finally:
              if closep:
--- 474,479 ----
                  tokenize.tokenize(fp.readline, eater)
              except tokenize.TokenError, e:
!                 print >> sys.stderr, '%s: %s, line %d, column %d' % (
!                     e[0], filename, e[1][0], e[1][1])
          finally:
              if closep: