meaningless.utilities package¶
Exceptions¶
- exception meaningless.utilities.exceptions.BaseError¶
Bases:
Exception
- exception meaningless.utilities.exceptions.InvalidPassageError(book, chapter_from, passage_from, chapter_to, passage_to, translation)¶
Bases:
BaseError
An exception thrown when processing a non-existent passage (or passage range)
- exception meaningless.utilities.exceptions.InvalidSearchError(url)¶
Bases:
BaseError
An exception thrown when searching for an invalid passage on the Bible Gateway site
YAML File Interface¶
- meaningless.utilities.yaml_file_interface.read(data_file)¶
A helper function to read a YAML data file
- Parameters:
data_file (str) – Path the data file to read
- Returns:
Contents of the file as an object. Raises an exception when a read problem occurs.
- Return type:
dict
- meaningless.utilities.yaml_file_interface.write(data_file, document)¶
A helper function to write to a YAML data file. Note that Unix line endings (LF) are used.
- Parameters:
data_file (str) – Path to the data file to write to
document (dict) – In-memory YAML structure, usually a dictionary
- Returns:
Returns 1 on success. Raises an exception when a write problem occurs.
- Return type:
int
JSON File Interface¶
- meaningless.utilities.json_file_interface.read(data_file)¶
A helper function to read a JSON data file
- Parameters:
data_file (str) – Path the data file to read
- Returns:
Contents of the file as an object. Raises an exception when a read problem occurs.
- Return type:
dict
- meaningless.utilities.json_file_interface.write(data_file, document)¶
A helper function to write to a JSON data file.
- Parameters:
data_file (str) – Path to the data file to write to
document (dict) – In-memory JSON structure, usually a dictionary
- Returns:
Returns 1 on success. Raises an exception when a write problem occurs.
- Return type:
int
XML File Interface¶
- meaningless.utilities.xml_file_interface.read(data_file)¶
A helper function to read a XML data file. Note that the input data must adhere to the following conventions:
The top-level tag is called ‘root’.
All <book> tags must have a “tag” attribute.
All <chapter> tags must have a “tag” attribute and must be nested within a <book> tag.
All <passage> tags must have a “tag” attribute and must be nested within a <chapter> tag.
If the XML data file is valid, the returned object will differ from the XML data file in the following ways:
Leading and trailing underscores will be removed.
All other underscores will be converted into spaces.
All keys will be converted to title case (all first letters of each word are capitalised)
- Parameters:
data_file (str) – Path to the data file to read
- Returns:
Contents of the file as an object. Raises an exception when a read problem occurs.
- Return type:
dict
- meaningless.utilities.xml_file_interface.write(data_file, document)¶
A helper function to write to a XML data file. Note that the input data must adhere to the following conventions:
If a top-level key is named ‘Info’, it must be a mapping of string keys to string values.
All other top-level keys map to a 3-layer dictionary or similar data structure with key-value pairs.
The 3rd layer of this data structure is a mapping of string keys to string values.
- Parameters:
data_file (str) – Path to the data file to write to
document (dict) – In-memory data structure, usually a dictionary
- Returns:
Returns 1 on success. Raises an exception when a write problem occurs.
- Return type:
int
CSV File Interface¶
- meaningless.utilities.csv_file_interface.read(data_file)¶
A helper function to read a CSV data file. Note that the file data must adhere to the following conventions:
A header row is included as the first line.
All data is contained within the first 8 columns.
- Parameters:
data_file (str) – Path the data file to read
- Returns:
Contents of the file as an object. Raises an exception when a read problem occurs.
- Return type:
dict
- meaningless.utilities.csv_file_interface.write(data_file, document)¶
A helper function to write to a CSV data file. Note that the input data must adhere to the following conventions:
The input document is a dictionary.
There is a top-level key called ‘Info’, with string values for the following keys: ‘Language’, ‘Translation’, ‘Timestamp’, ‘Meaningless’
There is at least one other top-level key-value pair, mapping to a dictionary of dictionaries.
There are no keys or values with the value set as None (excluding the sub-keys under the top-level ‘Info’ key).
- Parameters:
data_file (str) – Path to the data file to write to
document (dict) – In-memory data structure, usually a dictionary
- Returns:
Returns 1 on success. Raises an exception when a write problem occurs.
- Return type:
int