[open-ils-commits] r8216 - in trunk/build/i18n: . tests

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Dec 14 22:22:31 EST 2007


Author: dbs
Date: 2007-12-14 22:01:32 -0500 (Fri, 14 Dec 2007)
New Revision: 8216

Modified:
   trunk/build/i18n/Makefile
   trunk/build/i18n/tests/testpo.py
Log:
Add a PROJECT parameter for variable locale support.
Make testpo.py able to run from within any directory.


Modified: trunk/build/i18n/Makefile
===================================================================
--- trunk/build/i18n/Makefile	2007-12-15 02:58:43 UTC (rev 8215)
+++ trunk/build/i18n/Makefile	2007-12-15 03:01:32 UTC (rev 8216)
@@ -1,5 +1,6 @@
 POOUTDIR=po
 POINDIR=po
+PROJECT=locale
 LOCALE=fr-CA
 DTDDIR=../../Open-ILS/web/opac/locale
 PROPSDIR=../../Open-ILS/xul/staff_client/chrome/locale
@@ -37,7 +38,7 @@
 	@echo "Generated new PO files for locale $(LOCALE)"
 
 # Generate a new set of POT files and entityized fieldmapper IDL
-newpot: dtds2pot fmidl2pot fmidl2ent props2pot sql2pot
+newpot: dtds2pot fmidl2pot fmidl2fmidlent props2pot sql2pot
 	@echo "Generated new POT files"
 
 # Generate DTD, JavaScript message catalogs, fieldmapper IDL,
@@ -63,19 +64,19 @@
 	@moz2po -P $(PROGRESS) -o $(POOUTDIR) -i $(PROPSDIR)/en-US/ 2>&1
 
 po2dtds:
-	@po2moz $(PROGRESS) -o locale/$(LOCALE) -t $(DTDDIR)/en-US/ -i $(POINDIR)/$(LOCALE) 2>&1
+	@po2moz $(PROGRESS) -o $(PROJECT)/$(LOCALE) -t $(DTDDIR)/en-US/ -i $(POINDIR)/$(LOCALE) 2>&1
 
 po2props:
-	@po2moz $(PROGRESS) -o locale/$(LOCALE) -t $(PROPSDIR)/en-US/ -i $(POINDIR)/$(LOCALE) 2>&1
+	@po2moz $(PROGRESS) -o $(PROJECT)/$(LOCALE) -t $(PROPSDIR)/en-US/ -i $(POINDIR)/$(LOCALE) 2>&1
 
 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)
+	scripts/db-seed-i18n.py --sql $(POINDIR)/$(LOCALE)/$(SQLPO) --locale $(LOCALE) --output $(PROJECT)/$(LOCALE)/$(SQLOUT)
 
 # Generate a fieldmapper IDL file that uses entities instead of hard-coded strings
-fmidlpo2fmidlent:
+fmidl2fmidlent:
 	@scripts/fieldmapper.py --convert $(FMIDLSRC) --output $(POOUTDIR)/$(FMIDLENT)
 
 # Generate a POT file for translating the entity values
@@ -84,4 +85,4 @@
 
 # Generate a set of entity declarations from a PO file
 fmidlpo2entity:
-	@scripts/fieldmapper.py --entity $(POINDIR)/$(LOCALE)/$(FMIDLOUT) --output locale/$(LOCALE)/$(FMIDLENTITY)
+	@scripts/fieldmapper.py --entity $(POINDIR)/$(FMIDLOUT) --output $(PROJECT)/$(LOCALE)/$(FMIDLENTITY)

Modified: trunk/build/i18n/tests/testpo.py
===================================================================
--- trunk/build/i18n/tests/testpo.py	2007-12-15 02:58:43 UTC (rev 8215)
+++ trunk/build/i18n/tests/testpo.py	2007-12-15 03:01:32 UTC (rev 8216)
@@ -18,34 +18,34 @@
 
     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')
+    locale = 'll-LL'
+    locale_dir = 'tests/tmp/po/ll-LL'
+    project_dir = 'tests/tmp/locale'
+    po_tmp_dirs = (project_dir + '/' + locale, project_dir, locale_dir, pot_dir, project_dir, 'tests/tmp')
+    newdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
 
     def setUp(self):
+        print os.getcwd()
+        os.chdir(self.newdir)
         self.tearDown()
         devnull = open('/dev/null', 'w')
         os.mkdir('tests/tmp')
+        os.mkdir(self.project_dir)
         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()
+        proc = subprocess.Popen(('make', 'LOCALE=ll-LL', 'PROJECT=tests/tmp/locale', 'POINDIR=tests/tmp/po', 'POOUTDIR=tests/tmp/po', 'newproject'), 0, None, None, devnull, devnull).wait()
         devnull.close()
 
     def tearDown(self):
-        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 root, dirs, files in os.walk(os.path.join(self.newdir, 'tests/tmp'), topdown=False):
+            for name in files:
+                os.remove(os.path.join(root, name))
+            for name in dirs:
+                os.rmdir(os.path.join(root, name))
+        if os.access(os.path.join(self.newdir, 'tests/tmp'), os.F_OK):
+            os.rmdir(os.path.join(self.newdir, 'tests/tmp'))
 
-        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
@@ -89,7 +89,7 @@
         os.rename(testpo, commonpo)
 
         # Create the "translated" properties file
-        commonprops = os.path.join(self.locale_dir, 'common.properties')
+        commonprops = os.path.join(self.project_dir, self.locale, 'common.properties')
         testprops = os.path.join(self.locale_dir, 'test.properties')
         commonfile = open(commonprops)
         testfile = open(testprops, 'w')
@@ -164,5 +164,4 @@
         self.assertEqual(filecmp.cmp(commonprops, testprops), 1)
 
 if __name__ == '__main__':
-    os.chdir('..')
     unittest.main()



More information about the open-ils-commits mailing list