[sword-svn] r490 - trunk/modules/python

refdoc at crosswire.org refdoc at crosswire.org
Mon Dec 29 10:19:47 MST 2014


Author: refdoc
Date: 2014-12-29 10:19:47 -0700 (Mon, 29 Dec 2014)
New Revision: 490

Modified:
   trunk/modules/python/usfm2osis.py
Log:
added -l LANGUAGE commandline option


Modified: trunk/modules/python/usfm2osis.py
===================================================================
--- trunk/modules/python/usfm2osis.py	2014-12-09 14:27:57 UTC (rev 489)
+++ trunk/modules/python/usfm2osis.py	2014-12-29 17:19:47 UTC (rev 490)
@@ -1411,6 +1411,7 @@
     print('  -e ENCODING      input encoding override (default is to read the USFM file\'s')
     print('                     \\ide value or assume UTF-8 encoding in its absence)')
     print('  -h, --help       print this usage information')
+    print('  -l LANGUAGE      input language code - (default "und")')
     print('  -o FILENAME      output filename (default is: <osisWork>.osis.xml)')
     print('  -r               enable relaxed markup processing (for non-standard USFM)')
     print('  -s mode          set book sorting mode: natural (default), alpha, canonical,')
@@ -1511,7 +1512,16 @@
             relaxedConformance = True
             bookDict = dict(list(bookDict.items()) + list(addBookDict.items()))
             inputFilesIdx += 1
-
+        
+        if '-l' in sys.argv:
+            i = sys.argv.index('-l')+1
+            if len(sys.argv) < i+1:
+                printUsage()
+                                    
+            language = sys.argv[i]
+            inputFilesIdx += 2 #increment 2, reflecting 2 args for -l   
+        else: language = 'und'
+        
         if '-s' in sys.argv:
             i = sys.argv.index('-s')+1
             if len(sys.argv) < i+1:
@@ -1567,7 +1577,7 @@
             osisSegment[k]=v
 
         print('Assembling OSIS document')
-        osisDoc = '<osis xmlns="http://www.bibletechnologies.net/2003/OSIS/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.'+osisVersion+'.xsd">\n<osisText osisRefWork="Bible" xml:lang="und" osisIDWork="' + osisWork + '">\n<header>\n<work osisWork="' + osisWork + '"/>\n</header>\n'
+        osisDoc = '<osis xmlns="http://www.bibletechnologies.net/2003/OSIS/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.'+osisVersion+'.xsd">\n<osisText osisRefWork="Bible" xml:lang="' + language + '" osisIDWork="' + osisWork + '">\n<header>\n<work osisWork="' + osisWork + '"/>\n</header>\n'
 
         unhandledTags = set()
         for doc in usfmDocList:




More information about the sword-cvs mailing list