Core

cihai.core.Cihai is the application object that owns configuration, database access, and datasets. Most code creates one instance, runs cihai.core.Cihai.bootstrap() when needed, then queries the attached datasets.

Cihai core functionality.

exception cihai.core.CihaiConfigError
exception[source]
exception[source]
exception cihai.core.CihaiConfigError

Bases: CihaiException

Cihai Configuration error.

cihai.core.is_valid_config(config)
function[source]
function[source]
cihai.core.is_valid_config(config)

Upcast cihai configuration.

NOTE: This does not validate configuration yet!

Parameters:

config (dict[str, object])

Return type:

TypeGuard[ConfigDict]

class cihai.core.Cihai
class cihai.core.Cihai

Bases: object

Central application object.

By default, this automatically adds the UNIHAN dataset.

Notes

Inspired by the early pypa/warehouse application object.

Configuration templates

The config dict parameter supports a basic template system for replacing XDG Base Directory directory variables, tildes and environmentas variables. This is done by passing the option dict through cihai.config.expand_config() during initialization.

Examples

To use cihai programmatically, invoke and install the UNIHAN dataset — see Examples for a runnable walkthrough based on examples/basic_usage.py.

is_bootstrapped can check if the system has the database installed.