summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanilo Šegan <danilo@src.gnome.org>2006-10-20 17:34:36 +0000
committerDanilo Šegan <danilo@src.gnome.org>2006-10-20 17:34:36 +0000
commit96ad7c12d51b9bb14583335486fab58eb1f57646 (patch)
tree876196144bd90811bfb6a50c9e4d205f79a457fb
parentf5264ef90edeaf2aa93ea8711c5933d798163869 (diff)
downloadgnome-doc-utils-96ad7c12d51b9bb14583335486fab58eb1f57646.tar.gz
Improve speed with Alexander Nedotsukov patch.
-rw-r--r--xml2po/ChangeLog5
-rw-r--r--xml2po/tests/ChangeLog4
-rwxr-xr-xxml2po/tests/test.py6
-rwxr-xr-xxml2po/xml2po.py22
4 files changed, 26 insertions, 11 deletions
diff --git a/xml2po/ChangeLog b/xml2po/ChangeLog
index 4edc7e6..ed468a8 100644
--- a/xml2po/ChangeLog
+++ b/xml2po/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-20 Danilo Šegan <danilo@gnome.org>
+
+ * xml2po.py: Improve speed with Alexander Nedotsukov's patch from
+ bug #363451.
+
2006-05-14 Danilo Šegan <danilo@gnome.org>
* modes/docbook.py (docbookXmlMode.postProcessXmlTranslation):
diff --git a/xml2po/tests/ChangeLog b/xml2po/tests/ChangeLog
index acb317e..edf9f3c 100644
--- a/xml2po/tests/ChangeLog
+++ b/xml2po/tests/ChangeLog
@@ -1,3 +1,7 @@
+2006-10-20 Danilo Šegan <danilo@gnome.org>
+
+ * test.py: Pass PYTHONPATH to test commands.
+
2006-04-01 Danilo Šegan <danilo@gnome.org>
* test.py (SIMPLETESTS): Added ubuntu-mode.
diff --git a/xml2po/tests/test.py b/xml2po/tests/test.py
index aaed63a..02387e0 100755
--- a/xml2po/tests/test.py
+++ b/xml2po/tests/test.py
@@ -23,12 +23,12 @@ if len(sys.argv) > 1:
for opt in sys.argv[2:]:
myopts += " " + opt
output = input.replace(".xml", ".xml.out")
- fullcommand = "../xml2po %s %s | sed 's/\"POT-Creation-Date: .*$/\"POT-Creation-Date: \\\\n\"/' | diff -u %s -" % (myopts, input, pot)
+ fullcommand = "PYTHONPATH=../modes ../xml2po %s %s | sed 's/\"POT-Creation-Date: .*$/\"POT-Creation-Date: \\\\n\"/' | diff -u %s -" % (myopts, input, pot)
#print >>sys.stderr, fullcommand
ret = os.system(fullcommand)
if ret:
print "Problem: extraction from '%s'" % (input)
- fullcommand = "../xml2po -p %s %s %s | diff -u %s -" % (po, myopts, input, output)
+ fullcommand = "PYTHONPATH=../modes ../xml2po -p %s %s %s | diff -u %s -" % (po, myopts, input, output)
#print >>sys.stderr, fullcommand
ret = os.system(fullcommand)
if ret:
@@ -42,6 +42,6 @@ else:
print "WARNING: Test %s failed." % (t)
for t in OTHERTESTS:
- if os.system("cd %s && ./%s" % (t[0], t[1])):
+ if os.system("cd %s && PYTHONPATH=../../modes ./%s" % (t[0], t[1])):
print "WARNING: Test %s failed." % (t[0])
diff --git a/xml2po/xml2po.py b/xml2po/xml2po.py
index 477bfc0..58dc354 100755
--- a/xml2po/xml2po.py
+++ b/xml2po/xml2po.py
@@ -242,14 +242,10 @@ def getTranslation(text, spacepreserve = 0):
text = normalizeString(text, not spacepreserve)
if (text.strip() == ''):
return text
- file = open(mofile, "rb")
- if file:
- myfallback = NoneTranslations()
- gt = gettext.GNUTranslations(file)
- gt.add_fallback(myfallback)
- if gt:
- res = gt.ugettext(text.decode('utf-8'))
- return res
+ global gt
+ if gt:
+ res = gt.ugettext(text.decode('utf-8'))
+ return res
return text
@@ -648,6 +644,7 @@ default_mode = 'docbook'
filename = ''
origxml = ''
mofile = ''
+gt = None
ultimate = [ ]
ignored = [ ]
filenames = [ ]
@@ -764,6 +761,15 @@ if mode=='merge' and mofile=='':
print >> sys.stderr, "Error: You must specify MO file when merging translations."
sys.exit(3)
+if mofile:
+ try:
+ file = open(mofile, "rb")
+
+ gt = gettext.GNUTranslations(file)
+ gt.add_fallback(NoneTranslations())
+ except:
+ print >> sys.stderr, "Can't open MO file '%s'." % (mofile)
+
ultimate_tags = read_finaltags(ultimate)
ignored_tags = read_ignoredtags(ignored)