summaryrefslogtreecommitdiffstats
path: root/modules/python
diff options
context:
space:
mode:
authorChris Little <chrislit@crosswire.org>2012-08-25 01:28:41 +0000
committerChris Little <chrislit@crosswire.org>2012-08-25 01:28:41 +0000
commit9b7816f7f33078c040afdb966aad982a74b01956 (patch)
tree405b95fa5641ea6ea44fda760d37eb6b166b2916 /modules/python
parent2b190ed2f8be9d80644d68fdd3e6a490f1210508 (diff)
downloadsword-tools-9b7816f7f33078c040afdb966aad982a74b01956.tar.gz
some changes from 2to3 util
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@390 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'modules/python')
-rwxr-xr-xmodules/python/usfm2osis.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/modules/python/usfm2osis.py b/modules/python/usfm2osis.py
index 20d5b58..30c7c1e 100755
--- a/modules/python/usfm2osis.py
+++ b/modules/python/usfm2osis.py
@@ -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 @@ def convertToOSIS(sFile):
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 @@ def convertToOSIS(sFile):
supported: ~, //, \pb
"""
# ~
- osis = osis.replace('~', '\uA0')
+ osis = osis.replace('~', '\u00A0')
# //
osis = osis.replace('//', '<lb type="x-optional"/>')
@@ -1069,7 +1071,7 @@ def convertToOSIS(sFile):
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 @@ def convertToOSIS(sFile):
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 writeOSISFooter(oFile):
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 __name__ == "__main__":
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 __name__ == "__main__":
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.')