summaryrefslogtreecommitdiffstats
path: root/modules/python
diff options
context:
space:
mode:
authorChris Little <chrislit@crosswire.org>2012-08-12 18:32:31 +0000
committerChris Little <chrislit@crosswire.org>2012-08-12 18:32:31 +0000
commitda6c19834d117055cd839fbd84bc34841787764c (patch)
tree714c47d29481052d323e02c5a83828e19d21cfd9 /modules/python
parent3992fba2eb6d5231dd72416502c03e70b75835c9 (diff)
downloadsword-tools-da6c19834d117055cd839fbd84bc34841787764c.tar.gz
added fallback for handling descending verse ranges, e.g. \v 9-5 (treated as \v 9-9)
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@383 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'modules/python')
-rwxr-xr-xmodules/python/usfm2osis.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/python/usfm2osis.py b/modules/python/usfm2osis.py
index cd99288..664cfdd 100755
--- a/modules/python/usfm2osis.py
+++ b/modules/python/usfm2osis.py
@@ -999,11 +999,12 @@ def convertToOSIS(sFile):
def processOsisIDs(osis):
+ # TODO: add support for subverses, including in ranges/series, e.g. Matt.1.1!b-Matt.2.5,Matt.2.7!a
# expand verse ranges, series
def expandRange(vRange):
vRange = re.findall(r'\d+', vRange)
osisID = list()
- for n in range(int(vRange[0]), int(vRange[1])+1):
+ for n in range(int(vRange[0]), max(int(vRange[0]), int(vRange[1]))+1):
osisID.append('$BOOK$.$CHAP$.'+str(n))
return ' '.join(osisID)
osis = re.sub(r'\$BOOK\$\.\$CHAP\$\.(\d+-\d+)"', lambda m: expandRange(m.group(1))+'"', osis)