nbiatoolkit.utils.parsers

Functions

clean_html(→ str)

Cleans the given HTML string by removing HTML tags and replacing special characters.

convertMillis(→ str)

Convert milliseconds to a formatted date string.

convertDateFormat(→ str)

Converts the input date to the desired format.

parse_response(→ List[dict[Any, Any]])

Response will be either JSON or bytes

Module Contents

nbiatoolkit.utils.parsers.clean_html(html_string: str) str[source]

Cleans the given HTML string by removing HTML tags and replacing special characters.

Parameters:

html_string (str) – The input HTML string to be cleaned.

Returns:

The cleaned text content without HTML tags and special characters.

Return type:

str

nbiatoolkit.utils.parsers.convertMillis(millis: int) str[source]

Convert milliseconds to a formatted date string.

Parameters:

millis (int) – The number of milliseconds to convert.

Returns:

The formatted date string in the format ‘YYYY-MM-DD’.

Return type:

str

Raises:

AssertionError – If the input is not an integer.

nbiatoolkit.utils.parsers.convertDateFormat(input_date: str | datetime.datetime, format: str = '%Y/%m/%d') str[source]

Converts the input date to the desired format.

Parameters:

input_date (str) – The date to be converted.

Returns:

The converted date in the format “YYYY/MM/DD”.

Return type:

str

Raises:

ValueError – If the input date has an invalid format.

nbiatoolkit.utils.parsers.parse_response(response: requests.Response) List[dict[Any, Any]][source]

Response will be either JSON or bytes