cli_utils.py

View code on Github

Utility functions for the Scribe-Data CLI.

scribe_data.cli.cli_utils.correct_data_type(data_type: str) str | None[source]

Correct common versions of data type arguments to their standardized form.

Parameters:
data_typestr

The data type to potentially correct.

Returns:
str

The data_type value or a corrected version of it.

scribe_data.cli.cli_utils.print_formatted_data(data: dict | list, data_type: str) None[source]

Print formatted output from the Scribe-Data CLI.

Parameters:
datadict | list

The data to format and print.

data_typestr

The type of data being printed, used to determine formatting style.

scribe_data.cli.cli_utils.validate_language_and_data_type(language: str | list[str] | bool | None, data_type: str | list[str] | bool | None) bool[source]

Validate that the language and data type QIDs are not None.

Parameters:
languagestr or list

The language(s) to validate.

data_typestr or list

The data type(s) to validate.

Returns:
bool

True if validation passes, otherwise raises ValueError.

Raises:
ValueError

If any of the languages or data types is invalid, with all errors reported together.