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

chrislit at crosswire.org chrislit at crosswire.org
Fri Aug 24 18:28:42 MST 2012


Author: chrislit
Date: 2012-08-24 18:28:41 -0700 (Fri, 24 Aug 2012)
New Revision: 390

Modified:
   trunk/modules/python/usfm2osis.py
Log:
some changes from 2to3 util


Modified: trunk/modules/python/usfm2osis.py
===================================================================
--- trunk/modules/python/usfm2osis.py	2012-08-25 01:08:04 UTC (rev 389)
+++ trunk/modules/python/usfm2osis.py	2012-08-25 01:28:41 UTC (rev 390)
@@ -1,6 +1,8 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+from __future__ import print_function, unicode_literals
+
 date = '$Date$'
 rev = '$Rev$'
 id = '$Id$'
@@ -269,7 +271,7 @@
     global encoding
     global relaxedConformance
 
-    verbosePrint('Processing: ' + sFile)
+    verbosePrint(('Processing: ' + sFile))
 
     def cvtPreprocess(osis, relaxedConformance):
         # lines should never start with non-tags
@@ -854,7 +856,7 @@
         supported: ~, //, \pb
         """
         # ~
-        osis = osis.replace('~', '\uA0')
+        osis = osis.replace('~', '\u00A0')
 
         # //
         osis = osis.replace('//', '<lb type="x-optional"/>')
@@ -1069,7 +1071,7 @@
                 if encoding in aliases:
                     osis = codecs.open(sFile, 'r', encoding).read().strip() + '\n'
                 else:
-                    print('WARNING: Encoding "' + encoding + '" unknown, processing ' + sFile + ' as UTF-8.')
+                    print(('WARNING: Encoding "' + encoding + '" unknown, processing ' + sFile + ' as UTF-8.'))
                     encoding = 'utf-8'
 
 
@@ -1103,7 +1105,7 @@
     if DEBUG:
         localUnhandledTags = set(re.findall(r'(\\[^\s\*]+?\b\*?)', osis))
         if localUnhandledTags:
-            print('Unhandled USFM tags in ' + sFile + ': ' + ', '.join(localUnhandledTags) + ' (' + str(len(localUnhandledTags)) + ' total)')
+            print(('Unhandled USFM tags in ' + sFile + ': ' + ', '.join(localUnhandledTags) + ' (' + str(len(localUnhandledTags)) + ' total)'))
 
     return osis
 
@@ -1116,11 +1118,11 @@
 
 def verbosePrint(text):
     if verbose:
-        print text
+        print(text)
 
 def printUsage():
-    print('usfm2osis.py -- USFM ' + USFMversion + ' to OSIS ' + OSISversion + ' converter version ' + scriptVersion)
-    print('                Revision: ' + rev + ' (' + date + ')')
+    print(('usfm2osis.py -- USFM ' + USFMversion + ' to OSIS ' + OSISversion + ' converter version ' + scriptVersion))
+    print(('                Revision: ' + rev + ' (' + date + ')'))
     print('')
     print('Usage: usfm2osis.py <osisWork> [OPTION] ...  <USFM filename|wildcard> ...')
     print('')
@@ -1218,7 +1220,7 @@
 
         if '-r' in sys.argv:
             relaxedConformance = True
-            bookDict = dict(bookDict.items() + addBookDict.items())
+            bookDict = dict(list(bookDict.items()) + list(addBookDict.items()))
             inputFilesIdx += 1
 
         if '-s' in sys.argv:
@@ -1278,6 +1280,6 @@
         if unhandledTags:
             if verbose:
                 print('')
-            print('Unhandled USFM tags: ' + ', '.join(sorted(unhandledTags)) + ' (' + str(len(unhandledTags)) + ' total)')
+            print(('Unhandled USFM tags: ' + ', '.join(sorted(unhandledTags)) + ' (' + str(len(unhandledTags)) + ' total)'))
             if not relaxedConformance:
                 print('Consider using the -r option for relaxed markup processing.')




More information about the sword-cvs mailing list