summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9b5e4d4)
raw | patch | inline | side by side (parent: 9b5e4d4)
author | jhermann <jhermann@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 22 Nov 2001 01:15:26 +0000 (01:15 +0000) | ||
committer | jhermann <jhermann@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 22 Nov 2001 01:15:26 +0000 (01:15 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@416 57a73879-2fb5-44c3-a270-3262357dd7e2
tools/pygettext.py | patch | blob | history |
diff --git a/tools/pygettext.py b/tools/pygettext.py
index 82d1fefd18db4ac7f47e2b8f61c966d325c282fb..c7c9830c1acfd5e2adb8f8156fc1c934c6780a86 100644 (file)
--- a/tools/pygettext.py
+++ b/tools/pygettext.py
import fintl
_ = fintl.gettext
except ImportError:
- def _(s): return s
+ _ = lambda s: s
__doc__ = _("""pygettext -- Python equivalent of xgettext(1)
import sys
import time
import getopt
+import token
import tokenize
__version__ = '1.1'
self.__state = self.__waiting
elif ttype == tokenize.STRING:
self.__data.append(safe_eval(tstring))
- # TBD: should we warn if we seen anything else?
+ elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT,
+ token.NEWLINE, tokenize.NL]:
+ # warn if we seen anything else than STRING or whitespace
+ print >>sys.stderr, _('*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"') % {
+ 'token': tstring, 'file': self.__curfile, 'lineno': self.__lineno}
+ self.__state = self.__waiting
def set_filename(self, filename):
self.__curfile = filename
main()
# some more test strings
_(u'a unicode string')
+ _('*** Seen unexpected token "%(token)s"' % {'token': 'test'})
+ _('more' 'than' 'one' 'string')
+