Merge r16605 and r16607 from trunk for Dojo i18n enhancements:
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 11 Jun 2010 03:32:22 +0000 (03:32 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 11 Jun 2010 03:32:22 +0000 (03:32 +0000)
  * Create output directories if they do no exist (r16605)
  * Identify problem file when generating POT from Dojo resource files (r16607)

git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@16668 dcc99617-32d9-48b4-a31d-7c20da2025e4

build/i18n/scripts/dojo_resource.py

index 902498e..d33f655 100755 (executable)
@@ -35,6 +35,7 @@ import re
 import sys
 import simplejson
 import os.path
+import os
 
 class DojoResource (basel10n.BaseL10N):
     """
@@ -58,7 +59,11 @@ class DojoResource (basel10n.BaseL10N):
         # Avoid generating duplicate entries by keeping track of msgids
         msgids = dict()
 
-        bundle = simplejson.load(codecs.open(source, encoding='utf-8', mode='r'))
+       try:
+            bundle = simplejson.load(codecs.open(source, encoding='utf-8', mode='r'))
+       except ValueError:
+           print("Reading Dojo resource file %s" % (source))
+            raise
 
         for key, value in bundle.iteritems():
             if value in msgids:
@@ -110,6 +115,8 @@ def main():
     if options.pot:
         pot.get_strings(options.pot)
         if options.outfile:
+            if not os.path.exists(options.outfile):
+                os.makedirs(os.path.dirname(options.outfile))
             pot.savepot(options.outfile)
         else:
             sys.stdout.write(pot.pot.__str__())
@@ -119,6 +126,8 @@ def main():
         pot.loadpo(options.create)
         pot.create_bundle()
         if options.outfile:
+            if not os.path.exists(options.outfile):
+                os.makedirs(os.path.dirname(options.outfile))
             outfile = codecs.open(options.outfile, encoding='utf-8', mode='w')
             simplejson.dump(pot.msgs, outfile, indent=4)
         else: