from os import PathLike
from threading import Lock
from typing import BinaryIO, Callable, Sequence

PathTuple = tuple[str, PathLike[str], PathLike[str]]

PATH_TUPLE_PROCESS_METHOD_PREFIX: str
ADD_OPERATION: str
ADD_NO_REPLACE_OPERATION: str
REMOVE_OPERATION: str

class FileRotator:
    base_file_path: PathLike[str] | None
    maximum_file_size: int | None
    file_count: int | None
    current_file: BinaryIO | None
    current_file_size: int | None
    closed: bool

    def __init__(
        self,
        base_file_path: PathLike[str],
        maximum_file_size: int = ...,
        file_count: int = ...,
    ): ...
    def open(self): ...
    def close(self): ...
    def write(
        self, string_value: bytes | str, flush: bool = ..., encoding: str = ...
    ): ...
    def is_closed(self) -> bool: ...
    def _start_rotator(self): ...
    def _stop_rotator(self): ...
    def _open_current_file(self): ...
    def _close_current_file(self, rename: bool = ...): ...
    def _update_rotator(self): ...

class FileContext:
    def __init__(self): ...
    def resolve_file_path(self, file_path: PathLike[str]) -> PathLike[str]: ...
    def exists_file_path(self, file_path: PathLike[str]) -> bool: ...
    def is_directory_path(self, file_path: PathLike[str]) -> bool: ...
    def read_file(self, file_path: PathLike[str]) -> bytes: ...
    def write_file(self, file_path, file_contents: bytes): ...
    def remove_directory(
        self, directory_path: PathLike[str], handle_exception: bool = ...
    ): ...
    def remove_file(self, file_path: PathLike[str], handle_exception: bool = ...): ...
    def remove_directory_immediate(
        self, directory_path: PathLike[str], handle_exception: bool = ...
    ): ...
    def get_file_path(self, file_path: PathLike[str]) -> PathLike[str]: ...
    def _create_directory(self, file_path: PathLike[str]): ...

class TransactionContext:
    commit_callbacks_list: Sequence[Callable[[], None]]
    pre_commit_callbacks_list: Sequence[Callable[[], None]]
    rollback_callbacks_list: Sequence[Callable[[], None]]
    pre_rollback_callbacks_list: Sequence[Callable[[], None]]

    def __init__(self): ...
    def add_commit_callback(self, callback: Callable[[], None]): ...
    def remove_commit_callback(self, callback: Callable[[], None]): ...
    def add_pre_commit_callback(self, callback: Callable[[], None]): ...
    def remove_pre_commit_callback(self, callback: Callable[[], None]): ...
    def add_rollback_callback(self, callback: Callable[[], None]): ...
    def remove_rollback_callback(self, callback: Callable[[], None]): ...
    def add_pre_rollback_callback(self, callback: Callable[[], None]): ...
    def remove_pre_rollback_callback(self, callback: Callable[[], None]): ...
    def _call_commit_callbacks(self): ...
    def _call_pre_commit_callbacks(self): ...
    def _call_rollback_callbacks(self): ...
    def _call_pre_rollback_callbacks(self): ...

class FileImmediateContext(FileContext, TransactionContext):
    def __init__(self): ...
    def commit(self, remove_duplicates: bool = ...): ...
    def rollback(self): ...

class FileTransactionContext(FileContext, TransactionContext):
    transaction_level: int
    temporary_path: PathLike[str] | None
    path_tuples_list: list[PathTuple] | None
    access_lock: Lock | None

    def __init__(self, temporary_path: PathLike[str] | None = ...): ...
    def commit(self, remove_duplicates: bool = ...): ...
    def rollback(self): ...
    def _reset(self): ...
    def _cleanup(self): ...
    def _add_path_tuple(self, path_tuple: PathTuple): ...
    def _get_virtual_file_path(self, file_path: PathLike[str]): ...
    def _is_removed_file_path(self, file_path: PathLike[str]): ...
    def _process_path_tuple_add(self, path_tuple: PathTuple): ...
    def _process_path_tuple_add_no_replace(self, path_tuple: PathTuple): ...
    def _process_path_tuple_remove(self, path_tuple: PathTuple): ...
