bibleimport

class openlp.plugins.bibles.lib.bibleimport.BibleImport(*args, **kwargs)[source]

Bases: openlp.core.common.openlpmixin.OpenLPMixin, openlp.core.common.registryproperties.RegistryProperties, openlp.plugins.bibles.lib.db.BibleDB

Helper class to import bibles from a third party source into OpenLP

find_and_create_book(name, no_of_books, language_id, guess_id=None)[source]

Find the OpenLP book id and then create the book in this bible db

Parameters:
  • name – Name of the book. If None, then fall back to the guess_id Str
  • no_of_books – The total number of books contained in this bible Int
  • language_id – The OpenLP id of the language of this bible Int
  • guess_id – The guessed id of the book, used if name is None Int
Returns:

get_book_ref_id_by_name(book, maxbooks=66, language_id=None)[source]

Find the book id from the name or abbreviation of the book. If it doesn’t currently exist, ask the user.

Parameters:
  • book – The name or abbreviation of the book
  • maxbooks – The number of books in the bible
  • language_id – The language_id of the bible
Returns:

The id of the bible, or None

get_language(bible_name=None)[source]

If no language is given it calls a dialog window where the user could select the bible language. Return the language id of a bible.

Parameters:bible_name – The language the bible is.
get_language_id(file_language=None, bible_name=None)[source]

Get the language_id for the language of the bible. Fallback to user input if we cannot do this pragmatically.

Parameters:
  • file_language – Language of the bible. Possibly retrieved from the file being imported. Str
  • bible_name – Name of the bible to display on the get_language dialog. Str
Returns:

The id of a language Int or None

static is_compressed(file)[source]

Check if the supplied file is compressed

Parameters:file – A path to the file to check
parse_xml(filename, use_objectify=False, elements=None, tags=None)[source]

Parse and clean the supplied file by removing any elements or tags we don’t use. :param filename: The filename of the xml file to parse. Str :param use_objectify: Use the objectify parser rather than the etree parser. (Bool) :param elements: A tuple of element names (Str) to remove along with their content. :param tags: A tuple of element names (Str) to remove, preserving their content. :return: The root element of the xml document

register(wizard)[source]

This method basically just initialises the database. It is called from the Bible Manager when a Bible is imported. Descendant classes may want to override this method to supply their own custom initialisation as well.

Parameters:wizard – The actual Qt wizard form.
set_current_chapter(book_name, chapter_name)[source]
stop_import()[source]

Stops the import of the Bible.

validate_xml_file(filename, tag)[source]

Validate the supplied file

Parameters:
  • filename – The supplied file
  • tag – The expected root tag type
Returns:

True if valid. ValidationError is raised otherwise.