[sword-devel] usfm2osis.py

Chris Little chrislit at crosswire.org
Sat Aug 4 05:15:08 MST 2012

usfm2osis.py is posted now, at

It was developed on/for CPython 2.7.3, but 2.6+ should work. PyPy works 
fine too, but takes more than twice as long to run. And Jython is not 
supported at all.

The utility is not perfect & the code itself is a little messy at the 
moment, but it's much better than its Perl equivalent when it comes to 
generating valid OSIS. Every USFM tag in the 2.35 reference is processed 
in some way, but processing of only a fraction of the tags has been 
tested. (That's my next task.)

The command line syntax from the Perl equivalent can be used. Or use -h 
for the usage statement. In general, using the '-v -r' switches will be 
most common, I expect.

This utility is a bit slower than the Perl script was. Converting the 
WEB from USFM to OSIS takes about 7.5s on my system with 4 vCPUs, where 
the Perl script took about 4s as a single thread. But the Python version 
has the benefit of generating valid markup. (The script will fork as 
many processes as you have vCPUs, up to the number of books you are 

Bug reports are welcome if you try it, but this is still largely 
untested stuff, so expect bugs.

The other script in the above directory can be used to identify all of 
the USFM tags used in a set of files and will specify which of them are 
unknown to the USFM 2.35 reference.


More information about the sword-devel mailing list