| 1 |
import sys |
| 2 |
from _typeshed import StrOrBytesPath |
| 3 |
from collections.abc import Iterator, MutableMapping |
| 4 |
from dbm import _TFlags |
| 5 |
from types import TracebackType |
| 6 |
from typing import Any, TypeVar, overload |
| 7 |
from typing_extensions import Self |
| 8 |
|
| 9 |
__all__ = ["Shelf", "BsdDbShelf", "DbfilenameShelf", "open"] |
| 10 |
|
| 11 |
_T = TypeVar("_T") |
| 12 |
_VT = TypeVar("_VT") |
| 13 |
|
| 14 |
class Shelf(MutableMapping[str, _VT]): |
| 15 |
def __init__( |
| 16 |
self, dict: MutableMapping[bytes, bytes], protocol: int | None = None, writeback: bool = False, keyencoding: str = "utf-8" |
| 17 |
) -> None: ... |
| 18 |
def __iter__(self) -> Iterator[str]: ... |
| 19 |
def __len__(self) -> int: ... |
| 20 |
@overload |
| 21 |
def get(self, key: str, default: None = None) -> _VT | None: ... |
| 22 |
@overload |
| 23 |
def get(self, key: str, default: _VT) -> _VT: ... |
| 24 |
@overload |
| 25 |
def get(self, key: str, default: _T) -> _VT | _T: ... |
| 26 |
def __getitem__(self, key: str) -> _VT: ... |
| 27 |
def __setitem__(self, key: str, value: _VT) -> None: ... |
| 28 |
def __delitem__(self, key: str) -> None: ... |
| 29 |
def __contains__(self, key: str) -> bool: ... |
| 30 |
def __enter__(self) -> Self: ... |
| 31 |
def __exit__( |
| 32 |
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None |
| 33 |
) -> None: ... |
| 34 |
def __del__(self) -> None: ... |
| 35 |
def close(self) -> None: ... |
| 36 |
def sync(self) -> None: ... |
| 37 |
|
| 38 |
class BsdDbShelf(Shelf[_VT]): |
| 39 |
def set_location(self, key: str) -> tuple[str, _VT]: ... |
| 40 |
def next(self) -> tuple[str, _VT]: ... |
| 41 |
def previous(self) -> tuple[str, _VT]: ... |
| 42 |
def first(self) -> tuple[str, _VT]: ... |
| 43 |
def last(self) -> tuple[str, _VT]: ... |
| 44 |
|
| 45 |
class DbfilenameShelf(Shelf[_VT]): |
| 46 |
if sys.version_info >= (3, 11): |
| 47 |
def __init__( |
| 48 |
self, filename: StrOrBytesPath, flag: _TFlags = "c", protocol: int | None = None, writeback: bool = False |
| 49 |
) -> None: ... |
| 50 |
else: |
| 51 |
def __init__(self, filename: str, flag: _TFlags = "c", protocol: int | None = None, writeback: bool = False) -> None: ... |
| 52 |
|
| 53 |
if sys.version_info >= (3, 11): |
| 54 |
def open( |
| 55 |
filename: StrOrBytesPath, flag: _TFlags = "c", protocol: int | None = None, writeback: bool = False |
| 56 |
) -> Shelf[Any]: ... |
| 57 |
|
| 58 |
else: |
| 59 |
def open(filename: str, flag: _TFlags = "c", protocol: int | None = None, writeback: bool = False) -> Shelf[Any]: ... |