pysword package

Submodules

pysword.bible module

class pysword.bible.BlockType
BOOK = u'BOOK'
CHAPTER = u'CHAPTER'
VERSE = u'VERSE'
static get_file_ext_first_letter(block_type)

Return the first letter of modules file extensions based on the block type.

Parameters:block_type – Type of block, can be BOOK, CHAPTER or VERSE.
Returns:The first letter of modules file extensions based on the block type.
class pysword.bible.CompressType
BZIP2 = u'BZIP2'
LZSS = u'LZSS'
XZ = u'XZ'
ZIP = u'ZIP'
class pysword.bible.RawTextModule(*args, **kwargs)

Bases: pysword.bible.SwordBible

RawTextModule subclasses SwordBible allowing the RawText version of SWORD bibles to be parsed.

class pysword.bible.RawTextModule4(*args, **kwargs)

Bases: pysword.bible.RawTextModule

Subclass the RawTextModule to allow parsing SWORD bibles that use the Raw Text Specification.

class pysword.bible.SwordBible(module_path, module_type=None, versification=u'kjv', encoding=None, source_type=u'OSIS', block_type=u'BOOK', compress_type=u'ZIP', cipherkey=None)

Bases: object

SwordBible is an abstract base class containing the core common functionality required by each SWORD module type.

get(books=None, chapters=None, verses=None, clean=True, join='\n')

Retrieve the text for a given reference.

Parameters:
  • books – Single book name or an array of book names
  • chapters – Single chapter number or an array of chapter numbers
  • verses – Single verse number or an array of verse numbers
  • clean – True for cleaning text for tags, False to keep them.
  • join – The char/string that should be used to mark a new verse, defaults to newline
Returns:

the text for the reference.

get_iter(books=None, chapters=None, verses=None, clean=True)

Retrieve the text for a given reference as a dict.

Parameters:
  • books – Single book name or an array of book names
  • chapters – Single chapter number or an array of chapter numbers
  • verses – Single verse number or an array of verse numbers
  • clean – True for cleaning text for tags, False to keep them.
Returns:

iterator for the dict that contains the text

get_structure()

Retrieve the structure of this bible. :return: BibleStructure of this bible

class pysword.bible.SwordModuleType
RAWTEXT = u'rawtext'
RAWTEXT4 = u'rawtext4'
ZTEXT = u'ztext'
ZTEXT4 = u'ztext4'
class pysword.bible.Testament(testament_name, **kwargs)

Bases: object

Testament manages the file for each testament.

class pysword.bible.ZTextModule(*args, **kwargs)

Bases: pysword.bible.SwordBible

class pysword.bible.ZTextModule4(*args, **kwargs)

Bases: pysword.bible.ZTextModule

pysword.books module

class pysword.books.BibleStructure(versification, testaments=[u'ot', u'nt'])

Bases: object

find_book(name)

Find book

Parameters:name – The book to find
Returns:A tuple of the testament the book is in (‘ot’ or ‘nt’) and a BookStructure object.
Raises:ValueError – If the book is not in this BibleStructure.
get_books()

Return the bookstructure for this bible.

Returns:book structure
ref_to_indicies(books=None, chapters=None, verses=None)

Get references to indicies for given book(s), chapter(s) and verse(s).

Parameters:
  • books – Single book name or an array of book names
  • chapters – Single chapter number or an array of chapter numbers
  • verses – Single verse number or an array of verse numbers
Returns:

class pysword.books.BookStructure(name, osis_name, preferred_abbreviation, chapter_lengths)

Bases: object

chapter_offset(chapter_index)

Get offset based on chapter

Parameters:chapter_index – The chapter index to calculate from.
Returns:The calculated offset.
get_indicies(chapters=None, verses=None, offset=0)

Get indicies for given chapter(s) and verse(s).

Parameters:
  • chapters – Single chapter number or an array of chapter numbers
  • verses – Single verse number or an array of verse numbers
  • offset – The offset to used for this book when reading from file.
Returns:

An array of indicies.

name_matches(name)

Check if a name matches the name of this book.

Parameters:name – The name to match
Returns:True if matching else False
size

Size of book.

pysword.canon-parser module

pysword.canons module

pysword.cleaner module

class pysword.cleaner.Cleaner

Bases: object

clean(text)
class pysword.cleaner.GBFCleaner

Bases: pysword.cleaner.Cleaner

Class to clean text of GBF tags. GBF spec can be found here: http://ebible.org/bible/gbf.htm

clean(text)

Clean text for GBF tags.

Parameters:text – The text to be cleaned
Returns:The cleaned text is returned
class pysword.cleaner.OSISCleaner

Bases: pysword.cleaner.Cleaner

Class to clean text of OSIS tags. OSIS spec can be found here: http://www.bibletechnologies.net/

clean(text)

Clean text for OSIS tags.

Parameters:text – The text to be cleaned
Returns:The cleaned text is returned
class pysword.cleaner.ThMLCleaner

Bases: pysword.cleaner.Cleaner

Class to clean text of ThML tags. ThML spec can be found here: https://www.ccel.org/ThML/

clean(text)

Clean text for ThML tags.

Parameters:text – The text to be cleaned
Returns:The cleaned text is returned

pysword.modules module

class pysword.modules.SwordModules(paths=None, encoding=None)

Bases: object

Class used to parse module conf-files.

get_bible_from_module(module_key, cipher=None)

Return a SwordBible object for the key given.

Parameters:
  • module_key – The key to use for finding the module.
  • cipher – Cipher key to use to decrypt module. Overrules any cipher in the module conf
Returns:

a SwordBible object for the key given.

parse_modules()

Based on the datapath given to the constructor parse modules conf-files and return the result

Returns:A dict containing the data read from the conf files.
pysword.modules.get_platform_path()

Returns the default SWORD datapath for the current platform.

This is useful if you want to search for modules in both the default path and some additional paths.

pysword.utils module

pysword.utils.path_like_to_str(path)

Take an object and convert it to a string representation of a file path.

Parameters:path – The object to convert, should be an os.PathLike object, a pathlib.Path object or a str object
Returns:The string representation of the path

Module contents