[open-ils-commits] r8203 - in trunk/build/i18n: . po scripts tests tests/data

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Dec 11 23:59:00 EST 2007


Author: dbs
Date: 2007-12-11 23:38:24 -0500 (Tue, 11 Dec 2007)
New Revision: 8203

Modified:
   trunk/build/i18n/Makefile
   trunk/build/i18n/po/db.seed.pot
   trunk/build/i18n/po/fm_IDL.pot
   trunk/build/i18n/po/opac.dtd.pot
   trunk/build/i18n/scripts/basel10n.py
   trunk/build/i18n/tests/data/complex.po
   trunk/build/i18n/tests/data/complex.pot
   trunk/build/i18n/tests/data/sql2pot.pot
   trunk/build/i18n/tests/data/sqlsource.po
   trunk/build/i18n/tests/data/testidl.po
   trunk/build/i18n/tests/data/testidl.pot
   trunk/build/i18n/tests/testbase.py
   trunk/build/i18n/tests/testpo.py
Log:
Make unit tests less fragile.
Correct POT output where headers require an escaped \n.


Modified: trunk/build/i18n/Makefile
===================================================================
--- trunk/build/i18n/Makefile	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/Makefile	2007-12-12 04:38:24 UTC (rev 8203)
@@ -5,8 +5,12 @@
 PROPSDIR=../../Open-ILS/xul/staff_client/chrome/locale
 FMIDLSRC=../../Open-ILS/examples/fm_IDL.xml
 FMIDLOUT=fm_IDL.pot
+FMIDLENT=fm_IDL.xml
+FMIDLENTITY=fm_IDL.xml.ent
+FMIDLPO=fm_IDL.po
 SQLSRC=../../Open-ILS/src/sql/Pg/950.data.seed-values.sql
 SQLOUT=db.seed.pot
+SQLPO=db.seed.po
 PROGRESS=--progress none
 
 # This Makefile can be used to generate and update PO files for Evergreen,
@@ -23,23 +27,29 @@
 #
 # To update a set of translated PO files with new or changed en-US strings:
 #   make LOCALE=ll-LL updatepo
+#
+# To create a new set of project files (DTDs, JavaScript message catalogs):
+#   make LOCALE=ll-LL updatepo
 
-newpo: dtds2po props2po
+# Generate PO files from all POT files in POOUTDIR for locale LOCALE
+newpo: 
+	@pot2po $(PROGRESS) -i $(POOUTDIR) -o $(POOUTDIR)/$(LOCALE) 
 	@echo "Generated new PO files for locale $(LOCALE)"
 
-newpot: dtds2pot fmidl2pot props2pot sql2pot
+# Generate a new set of POT files and entityized fieldmapper IDL
+newpot: dtds2pot fmidl2pot fmidl2ent props2pot sql2pot
 	@echo "Generated new POT files"
 
-newproject: po2dtds po2props
-	@echo "Generated newly translated project files for locale $(LOCALE)"
+# Generate DTD, JavaScript message catalogs, fieldmapper IDL,
+# and SQL insert files from PO for locale LOCALE
+newproject: po2dtds po2props po2sql fmidlpo2entity
+	@echo "Generated project files for locale $(LOCALE)"
 
+# Update PO files with new and changed strings from POT files
 updatepo: 
 	@pot2po $(PROGRESS) -o $(POOUTDIR)/$(LOCALE) -i $(POOUTDIR) -t $(POOUTDIR)/$(LOCALE) 2>&1
 	@echo "Updated PO files for locale $(LOCALE)"
 
-updateproject: update_moz_dtds update_moz_props
-	@echo "Updated translated project files for locale $(LOCALE)"
-
 dtds2po:
 	@moz2po $(PROGRESS) -o $(POOUTDIR)/$(LOCALE) -i $(DTDDIR)/en-US/ 2>&1
 
@@ -61,11 +71,17 @@
 sql2pot:
 	@scripts/db-seed-i18n.py --pot $(SQLSRC) --output $(POOUTDIR)/$(SQLOUT)
 
+po2sql:
+	@scripts/db-seed-i18n.py --sql $(POINDIR)/$(LOCALE)/$(SQLPO) --locale $(LOCALE) --output locale/$(LOCALE)/$(SQLOUT)
+
+# Generate a fieldmapper IDL file that uses entities instead of hard-coded strings
+fmidlpo2fmidlent:
+	@scripts/fieldmapper.py --convert $(FMIDLSRC) --output $(POOUTDIR)/$(FMIDLENT)
+
+# Generate a POT file for translating the entity values
 fmidl2pot:
 	@scripts/fieldmapper.py --pot $(FMIDLSRC) --output $(POOUTDIR)/$(FMIDLOUT)
 
-update_moz_dtds:
-	@po2moz $(PROGRESS) -o locale/$(LOCALE) -t $(DTDDIR)/en-US/ -i $(POINDIR)/$(LOCALE) 2>&1
-
-update_moz_props:
-	@po2moz $(PROGRESS) -o locale/$(LOCALE) -t $(PROPSDIR)/en-US/ -i $(POINDIR)/$(LOCALE) 2>&1
+# Generate a set of entity declarations from a PO file
+fmidlpo2entity:
+	@scripts/fieldmapper.py --entity $(POINDIR)/$(LOCALE)/$(FMIDLOUT) --output locale/$(LOCALE)/$(FMIDLENTITY)

Modified: trunk/build/i18n/po/db.seed.pot
===================================================================
--- trunk/build/i18n/po/db.seed.pot	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/po/db.seed.pot	2007-12-12 04:38:24 UTC (rev 8203)
@@ -1,15 +1,15 @@
 # 
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
-"POT-Creation-Date: 2007-12-10 21:54:29-0400"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
-"Last-Translator: FULL NAME <EMAIL at ADDRESS>"
-"Language-Team: LANGUAGE <LL at li.org>"
-"MIME-Version: 1.0"
-"Content-Type: text/plain; charset=utf-8"
-"Content-Transfer-Encoding: 8-bit"
+"Project-Id-Version: Evergreen 1.4\n"
+"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
+"POT-Creation-Date: 2007-12-11 13:27:40-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8-bit\n"
 
 #: config.bib_source:3
 msgid "oclc"

Modified: trunk/build/i18n/po/fm_IDL.pot
===================================================================
--- trunk/build/i18n/po/fm_IDL.pot	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/po/fm_IDL.pot	2007-12-12 04:38:24 UTC (rev 8203)
@@ -1,15 +1,15 @@
 # 
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
-"POT-Creation-Date: 2007-12-10 21:54:25-0400"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
-"Last-Translator: FULL NAME <EMAIL at ADDRESS>"
-"Language-Team: LANGUAGE <LL at li.org>"
-"MIME-Version: 1.0"
-"Content-Type: text/plain; charset=utf-8"
-"Content-Transfer-Encoding: 8-bit"
+"Project-Id-Version: Evergreen 1.4\n"
+"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
+"POT-Creation-Date: 2007-12-11 13:27:35-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8-bit\n"
 
 #: field.aihu.org_unit.label:240 field.ancihu.org_unit.label:257
 msgid "Using Library"

Modified: trunk/build/i18n/po/opac.dtd.pot
===================================================================
--- trunk/build/i18n/po/opac.dtd.pot	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/po/opac.dtd.pot	2007-12-12 04:38:24 UTC (rev 8203)
@@ -2,9 +2,9 @@
 #, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4\n"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
-"POT-Creation-Date: 2007-11-19 13:21-0400\n"
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-12-11 13:27-0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
 "Language-Team: LANGUAGE <LL at li.org>\n"
@@ -631,8 +631,8 @@
 msgid "Pickup Location"
 msgstr ""
 
-#: myopac.holds.edit.cancel
-msgid "Edit/Cancel"
+#: myopac.holds.edit
+msgid "Edit"
 msgstr ""
 
 #: myopac.holds.status.none
@@ -651,10 +651,6 @@
 msgid "Ready for Pickup"
 msgstr ""
 
-#: myopac.holds.edit
-msgid "Edit"
-msgstr ""
-
 #: myopac.holds.verify
 msgid "If you wish to cancel the selected hold, click OK, otherwise click Cancel."
 msgstr ""
@@ -911,7 +907,7 @@
 msgstr ""
 
 #: myopac.summary.username.invalid
-msgid "Username cannot contain spaces"
+msgid "Username cannot contain spaces or have the same format as a barcode"
 msgstr ""
 
 #: myopac.summary.email.error
@@ -1668,7 +1664,7 @@
 msgstr ""
 
 #: result.sort_by.pubdate
-msgid "Sort Results by Publicate Date"
+msgid "Sort Results by Publication Date"
 msgstr ""
 
 #: result.limit2avail

Modified: trunk/build/i18n/scripts/basel10n.py
===================================================================
--- trunk/build/i18n/scripts/basel10n.py	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/scripts/basel10n.py	2007-12-12 04:38:24 UTC (rev 8203)
@@ -38,17 +38,17 @@
             version = 'Evergreen 1.4'
         if date is None:
             date = time.strftime("%Y-%m-%d %H:%M:%S") + '-0400'
-        self.pot.metadata['Project-Id-Version'] = version
+        self.pot.metadata['Project-Id-Version'] = version + r'\n'
         self.pot.metadata['Report-Msgid-Bugs-To'] = \
-            'open-ils-dev at list.georgialibraries.org'
+            'open-ils-dev at list.georgialibraries.org' + r'\n'
         # Cheat and hard-code the time zone offset
-        self.pot.metadata['POT-Creation-Date'] = date
-        self.pot.metadata['PO-Revision-Date'] = 'YEAR-MO-DA HO:MI+ZONE'
-        self.pot.metadata['Last-Translator'] = 'FULL NAME <EMAIL at ADDRESS>'
-        self.pot.metadata['Language-Team'] = 'LANGUAGE <LL at li.org>'
-        self.pot.metadata['MIME-Version'] = '1.0'
-        self.pot.metadata['Content-Type'] = 'text/plain; charset=utf-8'
-        self.pot.metadata['Content-Transfer-Encoding'] = '8-bit'
+        self.pot.metadata['POT-Creation-Date'] = date + r'\n'
+        self.pot.metadata['PO-Revision-Date'] = 'YEAR-MO-DA HO:MI+ZONE' + r'\n'
+        self.pot.metadata['Last-Translator'] = 'FULL NAME <EMAIL at ADDRESS>' + r'\n'
+        self.pot.metadata['Language-Team'] = 'LANGUAGE <LL at li.org>' + r'\n'
+        self.pot.metadata['MIME-Version'] = '1.0' + r'\n'
+        self.pot.metadata['Content-Type'] = 'text/plain; charset=utf-8' + r'\n'
+        self.pot.metadata['Content-Transfer-Encoding'] = '8-bit' + r'\n'
 
     def savepot(self, destination):
         """

Modified: trunk/build/i18n/tests/data/complex.po
===================================================================
--- trunk/build/i18n/tests/data/complex.po	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/tests/data/complex.po	2007-12-12 04:38:24 UTC (rev 8203)
@@ -1,15 +1,15 @@
 # 
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
-"POT-Creation-Date: 1999-12-31 23:59:59 -0400"
-"PO-Revision-Date: 2007-12-08 23:14:20 -0400"
-"Last-Translator: Dan Scott <dscott at laurentian.ca>"
-"Language-Team: fr-CA <LL at li.org>"
-"MIME-Version: 1.0"
-"Content-Type: text/plain; charset=utf-8"
-"Content-Transfer-Encoding: 8-bit"
+"Project-Id-Version: Evergreen 1.4\n"
+"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
+"POT-Creation-Date: 1999-12-31 23:59:59 -0400\n"
+"PO-Revision-Date: 2007-12-08 23:14:20 -0400\n"
+"Last-Translator: Dan Scott <dscott at laurentian.ca>\n"
+"Language-Team: fr-CA <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8-bit\n"
 
 #: 240:field.aihu.org_unit.label 257:field.ancihu.org_unit.label
 msgid "Using Library"

Modified: trunk/build/i18n/tests/data/complex.pot
===================================================================
--- trunk/build/i18n/tests/data/complex.pot	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/tests/data/complex.pot	2007-12-12 04:38:24 UTC (rev 8203)
@@ -1,15 +1,15 @@
 # 
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
-"POT-Creation-Date: 1999-12-31 23:59:59 -0400"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
-"Last-Translator: FULL NAME <EMAIL at ADDRESS>"
-"Language-Team: LANGUAGE <LL at li.org>"
-"MIME-Version: 1.0"
-"Content-Type: text/plain; charset=utf-8"
-"Content-Transfer-Encoding: 8-bit"
+"Project-Id-Version: Evergreen 1.4\n"
+"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
+"POT-Creation-Date: 1999-12-31 23:59:59 -0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8-bit\n"
 
 #: 240:field.aihu.org_unit.label 257:field.ancihu.org_unit.label
 msgid "Using Library"

Modified: trunk/build/i18n/tests/data/sql2pot.pot
===================================================================
--- trunk/build/i18n/tests/data/sql2pot.pot	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/tests/data/sql2pot.pot	2007-12-12 04:38:24 UTC (rev 8203)
@@ -1,15 +1,15 @@
 # 
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
+"Project-Id-Version: Evergreen 1.4\n"
+"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
 "POT-Creation-Date: 
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
-"Last-Translator: FULL NAME <EMAIL at ADDRESS>"
-"Language-Team: LANGUAGE <LL at li.org>"
-"MIME-Version: 1.0"
-"Content-Type: text/plain; charset=utf-8"
-"Content-Transfer-Encoding: 8-bit"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8-bit\n"
 
 #: config.bib_source:3
 msgid "oclc"

Modified: trunk/build/i18n/tests/data/sqlsource.po
===================================================================
--- trunk/build/i18n/tests/data/sqlsource.po	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/tests/data/sqlsource.po	2007-12-12 04:38:24 UTC (rev 8203)
@@ -1,15 +1,15 @@
 # 
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
-"POT-Creation-Date: 
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
-"Last-Translator: FULL NAME <EMAIL at ADDRESS>"
-"Language-Team: LANGUAGE <LL at li.org>"
-"MIME-Version: 1.0"
-"Content-Type: text/plain; charset=utf-8"
-"Content-Transfer-Encoding: 8-bit"
+"Project-Id-Version: Evergreen 1.4\n"
+"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
+"POT-Creation-Date: 1999-12-31 23:59:59 -0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8-bit\n"
 
 #: config.bib_source:3
 msgid "oclc"

Modified: trunk/build/i18n/tests/data/testidl.po
===================================================================
--- trunk/build/i18n/tests/data/testidl.po	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/tests/data/testidl.po	2007-12-12 04:38:24 UTC (rev 8203)
@@ -1,15 +1,15 @@
 # 
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
-"POT-Creation-Date: 
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
-"Last-Translator: FULL NAME <EMAIL at ADDRESS>"
-"Language-Team: LANGUAGE <LL at li.org>"
-"MIME-Version: 1.0"
-"Content-Type: text/plain; charset=utf-8"
-"Content-Transfer-Encoding: 8-bit"
+"Project-Id-Version: Evergreen 1.4\n"
+"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
+"POT-Creation-Date: 1999-12-31 23:59:59 -0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8-bit\n"
 
 #: field.auoi.org_unit.label:29
 msgid "Allowed Org Unit"

Modified: trunk/build/i18n/tests/data/testidl.pot
===================================================================
--- trunk/build/i18n/tests/data/testidl.pot	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/tests/data/testidl.pot	2007-12-12 04:38:24 UTC (rev 8203)
@@ -1,15 +1,15 @@
 # 
 msgid ""
 msgstr ""
-"Project-Id-Version: Evergreen 1.4"
-"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
+"Project-Id-Version: Evergreen 1.4\n"
+"Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org\n"
 "POT-Creation-Date: 
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
-"Last-Translator: FULL NAME <EMAIL at ADDRESS>"
-"Language-Team: LANGUAGE <LL at li.org>"
-"MIME-Version: 1.0"
-"Content-Type: text/plain; charset=utf-8"
-"Content-Transfer-Encoding: 8-bit"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8-bit\n"
 
 #: 29:field.auoi.org_unit.label
 msgid "Allowed Org Unit"

Modified: trunk/build/i18n/tests/testbase.py
===================================================================
--- trunk/build/i18n/tests/testbase.py	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/tests/testbase.py	2007-12-12 04:38:24 UTC (rev 8203)
@@ -59,9 +59,9 @@
         poload.loadpo(self.canonpo)
         pogen = basel10n.BaseL10N()
         pogen.pothead('Evergreen 1.4', '1999-12-31 23:59:59 -0400')
-        pogen.pot.metadata['PO-Revision-Date'] = '2007-12-08 23:14:20 -0400'
-        pogen.pot.metadata['Last-Translator'] = ' Dan Scott <dscott at laurentian.ca>'
-        pogen.pot.metadata['Language-Team'] = 'fr-CA <LL at li.org>'
+        pogen.pot.metadata['PO-Revision-Date'] = '2007-12-08 23:14:20 -0400\\n'
+        pogen.pot.metadata['Last-Translator'] = ' Dan Scott <dscott at laurentian.ca>\\n'
+        pogen.pot.metadata['Language-Team'] = 'fr-CA <LL at li.org>\\n'
         for msg in self.poentries:
             poe = polib.POEntry()
             for x in msg['occurences']:

Modified: trunk/build/i18n/tests/testpo.py
===================================================================
--- trunk/build/i18n/tests/testpo.py	2007-12-12 01:47:16 UTC (rev 8202)
+++ trunk/build/i18n/tests/testpo.py	2007-12-12 04:38:24 UTC (rev 8203)
@@ -11,29 +11,41 @@
 
 class TestPOFramework(unittest.TestCase):
 
-    po_sources = ('../../Open-ILS/web/opac/locale/en-US/*.dtd', \
-        '../../Open-ILS/xul/staff_client/chrome/locale/en-US/*.properties')
+    po_sources = ('../../Open-ILS/web/opac/locale/en-US/*.dtd',
+        '../../Open-ILS/xul/staff_client/chrome/locale/en-US/*.properties',
+        '../../Open-ILS/examples/fm_IDL.xml',
+        '../../Open-ILS/src/sql/Pg/950.data.seed-values.sql')
 
+    po_tmp_files = ('tests/tmp/po/test.properties.pot', 'tests/tmp/po/ll-LL/temp.properties.po')
+    pot_dir = 'tests/tmp/po'
+    locale_dir = 'tests/tmp/po/ll-LL/'
+    po_tmp_dirs = (locale_dir, locale_dir, pot_dir, 'tests/tmp')
+
     def setUp(self):
         self.tearDown()
         devnull = open('/dev/null', 'w')
-        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'newpo'), 0, None, None, devnull, devnull).wait()
-        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'newproject'), 0, None, None, devnull, devnull).wait()
+        os.mkdir('tests/tmp')
+        proc = subprocess.Popen(('cp', '-r', 'po', 'tests/tmp'), 0, None, None, devnull, devnull).wait()
+        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'newpot'), 0, None, None, devnull, devnull).wait()
+        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'newpo'), 0, None, None, devnull, devnull).wait()
+        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'newproject'), 0, None, None, devnull, devnull).wait()
         devnull.close()
 
     def tearDown(self):
-        tmpdirs = ('po/ll-LL', 'locale/ll-LL')
-        tmpfiles = ('po/test.properties.pot', 'locale/ll-LL/temp.properties.po')
-        for dir in tmpdirs:
-            if os.access(dir, os.F_OK):
-                for file in os.listdir(dir):
-                    os.remove(os.path.join(dir, file))
-                os.rmdir(dir)
+        for dir in self.po_tmp_dirs:
+            for root, dirs, files in os.walk(os.path.join(os.path.dirname(__file__), dir), topdown=False):
+                for name in files:
+                    os.remove(os.path.join(root, name))
+                for name in dirs:
+                    os.rmdir(os.path.join(root, name))
 
-        for file in tmpfiles:
+        for file in self.po_tmp_files:
             if os.access(file, os.F_OK):
                 os.remove(file)
 
+        if os.access('tests/tmp', os.F_OK):
+            os.rmdir('tests/tmp')
+
     def testnewpofiles(self):
         # Create a brand new set of PO files from our en-US project files.
         # Compare the files generated in the po/ll-LL directory with
@@ -43,9 +55,9 @@
             for path in glob.glob(po_dir):
                 po_files.append(os.path.basename(path) + '.po')
         po_files.sort()
-        new_pofiles = os.listdir('po/ll-LL/')
+        new_pofiles = os.listdir(self.locale_dir)
         new_pofiles.sort()
-        self.assertEqual(po_files, new_pofiles)
+        self.assertEqual(len(po_files), len(new_pofiles))
 
     def testnewprojectfiles(self):
         # Create a brand new set of project files from PO files.
@@ -55,17 +67,17 @@
             for path in glob.glob(po_dir):
                 moz_files.append(os.path.basename(path))
         moz_files.sort()
-        new_mozfiles = os.listdir('locale/ll-LL/')
+        new_mozfiles = os.listdir(self.locale_dir)
         new_mozfiles.sort()
-        self.assertEqual(moz_files, new_mozfiles)
+        self.assertEqual(len(moz_files), len(new_mozfiles))
 
     def testtranslatedfile(self):
         # "Translate" strings in a PO file, then generate the project
         # files to ensure that the translated string appears in the output.
 
         # Create the "translated" PO file
-        commonpo = 'po/ll-LL/common.properties.po'
-        testpo = 'po/ll-LL/test.properties.po'
+        commonpo = os.path.join(self.locale_dir, 'common.properties.po')
+        testpo = os.path.join(self.locale_dir, 'test.properties.po')
         commonfile = open(commonpo)
         testfile = open(testpo, 'w')
         for line in commonfile:
@@ -77,8 +89,8 @@
         os.rename(testpo, commonpo)
 
         # Create the "translated" properties file
-        commonprops = 'locale/ll-LL/common.properties'
-        testprops = 'locale/ll-LL/test.properties'
+        commonprops = os.path.join(self.locale_dir, 'common.properties')
+        testprops = os.path.join(self.locale_dir, 'test.properties')
         commonfile = open(commonprops)
         testfile = open(testprops, 'w')
         for line in commonfile:
@@ -89,7 +101,7 @@
 
         # Regenerate the project files to get the translated strings in place
         devnull = open('/dev/null', 'w')
-        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'updateproject'), 0, None, None, devnull, devnull).wait()
+        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'updateproject'), 0, None, None, devnull, devnull).wait()
 
         self.assertEqual(filecmp.cmp(commonprops, testprops), 1)
 
@@ -98,8 +110,8 @@
         # include the new strings
 
         # Create the "template" PO file
-        commonpo = 'po/ll-LL/common.properties.po'
-        testpo = 'po/ll-LL/test.properties.po'
+        commonpo = os.path.join(self.locale_dir, 'common.properties.po')
+        testpo = os.path.join(self.locale_dir, 'test.properties.po')
         commonfile = open(commonpo)
         testfile = open(testpo, 'w')
         for line in commonfile:
@@ -109,8 +121,8 @@
         testfile.close()
 
         # Create the test POT file
-        commonpot = 'po/common.properties.pot'
-        testpot = 'po/test.properties.pot'
+        commonpot = os.path.join(self.pot_dir, 'common.properties.pot')
+        testpot = os.path.join(self.pot_dir, 'test.properties.pot')
         commonfile = open(commonpot)
         testfile = open(testpot, 'w')
         for line in commonfile:
@@ -124,11 +136,11 @@
 
         # Update the PO files to get the translated strings in place
         devnull = open('/dev/null', 'w')
-        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'updatepo'), 0, None, None, devnull, devnull).wait()
+        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'updatepo'), 0, None, None, devnull, devnull).wait()
 
-        commonprops = 'po/ll-LL/common.properties.po'
-        tempprops = 'po/ll-LL/temp.properties.po'
-        testprops = 'po/ll-LL/test.properties.po'
+        commonprops = os.path.join(self.locale_dir, 'common.properties.po')
+        tempprops = os.path.join(self.locale_dir, 'temp.properties.po')
+        testprops = os.path.join(self.locale_dir, 'test.properties.po')
 
         # Munge the common file to make it what we expect it to be
         commonfile = open(commonprops, 'a+')



More information about the open-ils-commits mailing list