import logging
from collections.abc import Callable, Iterator
from typing import TypeVar
from typing_extensions import ParamSpec

logger: logging.Logger

_P = ParamSpec("_P")
_R = TypeVar("_R")

class Data:
    def __init__(self, **fields: str) -> None: ...
    def __getattr__(self, key: str) -> str: ...
    def __setattr__(self, key: str, value: str) -> None: ...
    def __dir__(self) -> list[str]: ...
    def __iter__(self) -> Iterator[tuple[str, str]]: ...

class Country(Data): ...
class Subdivision(Data): ...

def lazy_load(f: Callable[_P, _R]) -> Callable[_P, _R]: ...

class Database:
    data_class: type | str
    root_key: str | None
    no_index: list[str]
    filename: str
    factory: type
    objects: list[Data]
    index_names: set[str]
    indices: dict[str, dict[str, Data]]

    def __init__(self, filename: str) -> None: ...
    @lazy_load
    def add_entry(self, **kw: str) -> None: ...
    @lazy_load
    def remove_entry(self, **kw: str) -> None: ...
    @lazy_load
    def __iter__(self) -> Iterator[Data]: ...
    @lazy_load
    def __len__(self) -> int: ...
    @lazy_load
    def get(self, *, default: Data | None = ..., **kw: str) -> Data | None: ...
    @lazy_load
    def lookup(self, value: str) -> Data: ...
