CXCV/Python/Interfaces/Drivers/FilesDriverInterface.py

47 lines
1.3 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import Self, Any, Callable
from abc import ABC, abstractmethod
class FilesDriverInterface(ABC):
@abstractmethod
def fix_path(self:Self, path:str) -> str:pass
@abstractmethod
def exists(self:Self, path:str, analyze_roots:bool = True) -> bool:pass
@abstractmethod
def is_file(self:Self, path:str, analyze_roots:bool = True) -> bool:pass
@abstractmethod
def is_directory(self:Self, path:str, analyze_roots:bool = True) -> bool:pass
@abstractmethod
def get_absolute_path(self:Self, path:str) -> str|None:pass
@abstractmethod
def load(self:Self, path:str, mode:str = "r") -> bool:pass
@abstractmethod
def load_by_chunks(self:Self,
path:str,
callback:Callable[[bytes], None],
chunk_size:int = 4096
) -> None:pass
@abstractmethod
def save(self:Self, path:str, data:str|bytes, mode:str = "w") -> bool:pass
@abstractmethod
def load_json(self:Self,
inputs:Any|None,
only_dictionaries:bool = True
) -> tuple[dict[str, Any|None]|tuple[Any|None, ...]|list[Any|None], ...]:pass
@abstractmethod
def get_directory_path(self:Self, path:str) -> str:pass
@abstractmethod
def prepare_path(self:Self, path:str) -> bool:pass