"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "roundup/cgi/TAL/talgettext.py" between
roundup-1.6.1.tar.gz and roundup-2.0.0.tar.gz

About: Roundup is an highly customisable issue-tracking system with command-line, web and e-mail interfaces (written in Python).

talgettext.py  (roundup-1.6.1):talgettext.py  (roundup-2.0.0)
skipping to change at line 36 skipping to change at line 36
Options: Options:
-h / --help -h / --help
Print this message and exit. Print this message and exit.
-o / --output <file> -o / --output <file>
Output the translation .po file to <file>. Output the translation .po file to <file>.
-u / --update <file> -u / --update <file>
Update the existing translation <file> with any new translation strings Update the existing translation <file> with any new translation strings
found. found.
""" """
from __future__ import print_function
import sys import sys
import time import time
import getopt import getopt
import traceback import traceback
from roundup import __version__ from roundup import __version__
from roundup.cgi.TAL.HTMLTALParser import HTMLTALParser from roundup.cgi.TAL.HTMLTALParser import HTMLTALParser
from roundup.cgi.TAL.TALInterpreter import TALInterpreter from roundup.cgi.TAL.TALInterpreter import TALInterpreter
from roundup.cgi.TAL.DummyEngine import DummyEngine from roundup.cgi.TAL.DummyEngine import DummyEngine
#from ITALES import ITALESEngine #from ITALES import ITALESEngine
skipping to change at line 68 skipping to change at line 69
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
"Language-Team: LANGUAGE <LL@li.org>\\n" "Language-Team: LANGUAGE <LL@li.org>\\n"
"MIME-Version: 1.0\\n" "MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=CHARSET\\n" "Content-Type: text/plain; charset=CHARSET\\n"
"Content-Transfer-Encoding: ENCODING\\n" "Content-Transfer-Encoding: ENCODING\\n"
"Generated-By: talgettext.py %(version)s\\n" "Generated-By: talgettext.py %(version)s\\n"
''' '''
NLSTR = '"\n"' NLSTR = '"\n"'
try:
True
except NameError:
True=1
False=0
def usage(code, msg=''): def usage(code, msg=''):
# Python 2.1 required # Python 2.1 required
print >> sys.stderr, __doc__ print(__doc__, file=sys.stderr)
if msg: if msg:
print >> sys.stderr, msg print(msg, file=sys.stderr)
sys.exit(code) sys.exit(code)
class POTALInterpreter(TALInterpreter): class POTALInterpreter(TALInterpreter):
def translate(self, msgid, default, i18ndict=None, obj=None): def translate(self, msgid, default, i18ndict=None, obj=None):
# XXX is this right? # XXX is this right?
if i18ndict is None: if i18ndict is None:
i18ndict = {} i18ndict = {}
if obj: if obj:
i18ndict.update(obj) i18ndict.update(obj)
# XXX Mmmh, it seems that sometimes the msgid is None; is that really # XXX Mmmh, it seems that sometimes the msgid is None; is that really
skipping to change at line 163 skipping to change at line 158
# shamelessly cribbed from Python's Tools/i18n/msgfmt.py # shamelessly cribbed from Python's Tools/i18n/msgfmt.py
# 25-Mar-2003 Nathan R. Yergler (nathan@zope.org) # 25-Mar-2003 Nathan R. Yergler (nathan@zope.org)
# 14-Apr-2003 Hacked by Barry Warsaw (barry@zope.com) # 14-Apr-2003 Hacked by Barry Warsaw (barry@zope.com)
ID = 1 ID = 1
STR = 2 STR = 2
try: try:
lines = open(self._filename).readlines() lines = open(self._filename).readlines()
except IOError as msg: except IOError as msg:
print >> sys.stderr, msg print(msg, file=sys.stderr)
sys.exit(1) sys.exit(1)
section = None section = None
fuzzy = False fuzzy = False
# Parse the catalog # Parse the catalog
lno = 0 lno = 0
for l in lines: for l in lines:
lno += True lno += True
# If we get a comment line after a msgstr, this is a new entry # If we get a comment line after a msgstr, this is a new entry
skipping to change at line 205 skipping to change at line 200
# Skip empty lines # Skip empty lines
if not l.strip(): if not l.strip():
continue continue
# XXX: Does this always follow Python escape semantics? # XXX: Does this always follow Python escape semantics?
l = eval(l) l = eval(l)
if section == ID: if section == ID:
msgid += l msgid += l
elif section == STR: elif section == STR:
msgstr += '%s\n' % l msgstr += '%s\n' % l
else: else:
print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \ print('Syntax error on %s:%d' % (infile, lno),
'before:' 'before:', file=sys.stderr)
print >> sys.stderr, l print(l, file=sys.stderr)
sys.exit(1) sys.exit(1)
# Add last entry # Add last entry
if section == STR: if section == STR:
self.__add(msgid, msgstr, fuzzy) self.__add(msgid, msgstr, fuzzy)
def evaluate(self, expression): def evaluate(self, expression):
try: try:
return POEngine.evaluate(self, expression) return POEngine.evaluate(self, expression)
except TALESError: except TALESError:
pass pass
skipping to change at line 252 skipping to change at line 247
usage(0) usage(0)
elif opt in ('-o', '--output'): elif opt in ('-o', '--output'):
outfile = arg outfile = arg
elif opt in ('-u', '--update'): elif opt in ('-u', '--update'):
update_mode = True update_mode = True
if outfile is None: if outfile is None:
outfile = arg outfile = arg
engine = UpdatePOEngine(filename=arg) engine = UpdatePOEngine(filename=arg)
if not args: if not args:
print 'nothing to do' print('nothing to do')
return return
# We don't care about the rendered output of the .pt file # We don't care about the rendered output of the .pt file
class Devnull: class Devnull:
def write(self, s): def write(self, s):
pass pass
# check if we've already instantiated an engine; # check if we've already instantiated an engine;
# if not, use the stupidest one available # if not, use the stupidest one available
if not engine: if not engine:
skipping to change at line 275 skipping to change at line 270
# process each file specified # process each file specified
for filename in args: for filename in args:
try: try:
engine.file = filename engine.file = filename
p = HTMLTALParser() p = HTMLTALParser()
p.parseFile(filename) p.parseFile(filename)
program, macros = p.getCode() program, macros = p.getCode()
POTALInterpreter(program, macros, engine, stream=Devnull(), POTALInterpreter(program, macros, engine, stream=Devnull(),
metal=False)() metal=False)()
except: # Hee hee, I love bare excepts! except: # Hee hee, I love bare excepts!
print 'There was an error processing', filename print('There was an error processing', filename)
traceback.print_exc() traceback.print_exc()
# Now output the keys in the engine. Write them to a file if --output or # Now output the keys in the engine. Write them to a file if --output or
# --update was specified; otherwise use standard out. # --update was specified; otherwise use standard out.
if (outfile is None): if (outfile is None):
outfile = sys.stdout outfile = sys.stdout
else: else:
outfile = file(outfile, update_mode and "a" or "w") outfile = open(outfile, update_mode and "a" or "w")
catalog = {} catalog = {}
for domain in engine.catalog.keys(): for domain in engine.catalog.keys():
catalog.update(engine.catalog[domain]) catalog.update(engine.catalog[domain])
messages = catalog.copy() messages = catalog.copy()
try: try:
messages.update(engine.base) messages.update(engine.base)
except AttributeError: except AttributeError:
pass pass
if '' not in messages: if '' not in messages:
print >> outfile, pot_header % {'time': time.ctime(), print(pot_header % {'time': time.ctime(),
'version': __version__} 'version': __version__}, file=outfile)
msgids = catalog.keys()
# XXX: You should not sort by msgid, but by filename and position. (SR) # XXX: You should not sort by msgid, but by filename and position. (SR)
msgids.sort() msgids = sorted(catalog.keys())
for msgid in msgids: for msgid in msgids:
positions = catalog[msgid] positions = catalog[msgid]
for filename, position in positions: for filename, position in positions:
outfile.write('#: %s:%s\n' % (filename, position[0])) outfile.write('#: %s:%s\n' % (filename, position[0]))
outfile.write('msgid "%s"\n' outfile.write('msgid "%s"\n'
% msgid.replace('"', '\\"').replace("\n", '\\n"\n"')) % msgid.replace('"', '\\"').replace("\n", '\\n"\n"'))
outfile.write('msgstr ""\n') outfile.write('msgstr ""\n')
outfile.write('\n') outfile.write('\n')
 End of changes. 12 change blocks. 
19 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)