Skip to content

JABS Core Utils

JABS utilities

check_for_update()

Check PyPI for newer version of jabs-behavior-classifier.

Returns:

Name Type Description
tuple tuple[bool, str | None, str]

(has_update: bool, latest_version: str | None, current_version: str) - has_update: True if a newer version is available - latest_version: Latest version string from PyPI, or None if check failed - current_version: Current installed version string

get_bool_env_var(var_name, default_value=False)

Gets a boolean value from an environment variable.

Parameters:

Name Type Description Default
var_name

The name of the environment variable.

required
default_value

The default value to return if the variable is not set or invalid.

False

Returns:

Type Description
bool

A boolean value.

hash_file(file)

return hash

hide_stderr()

Context manager to temporarily suppress output to standard error (stderr).

Redirects all output sent to stderr to os.devnull while the context is active, restoring stderr to its original state upon exit.

Yields:

Name Type Description
int int

The file descriptor for stderr.

is_pypi_install()

Check if jabs-behavior-classifier was installed from PyPI.

Returns:

Name Type Description
bool bool

True if installed via pip from PyPI, False otherwise