In Dojo i18n script: create output directories if they don't exist
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 7 Jun 2010 05:15:52 +0000 (05:15 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 7 Jun 2010 05:15:52 +0000 (05:15 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16605 dcc99617-32d9-48b4-a31d-7c20da2025e4

build/i18n/scripts/dojo_resource.py

index 902498e..83fd013 100755 (executable)
@@ -35,6 +35,7 @@ import re
 import sys
 import simplejson
 import os.path
+import os
 
 class DojoResource (basel10n.BaseL10N):
     """
@@ -58,6 +59,7 @@ class DojoResource (basel10n.BaseL10N):
         # Avoid generating duplicate entries by keeping track of msgids
         msgids = dict()
 
+       #print("Reading Dojo resource file %s" % (source))
         bundle = simplejson.load(codecs.open(source, encoding='utf-8', mode='r'))
 
         for key, value in bundle.iteritems():
@@ -110,6 +112,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 +123,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: