Source code for credsweeper.file_handler.abstract_provider

import io
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Union, Tuple, Sequence

from credsweeper.config.config import Config
from credsweeper.file_handler.content_provider import ContentProvider


[docs] class AbstractProvider(ABC): """Base class for all files provider objects.""" def __init__(self, paths: Sequence[Union[str, Path, io.BytesIO, Tuple[Union[str, Path], io.BytesIO]]]) -> None: """Initialize Files Provider object for 'paths'. Args: paths: file paths list to scan or io.BytesIO or tuple with both """ self.paths = paths @property def paths(self) -> Sequence[Union[str, Path, io.BytesIO, Tuple[Union[str, Path], io.BytesIO]]]: """paths getter""" return self.__paths @paths.setter def paths(self, paths: Sequence[Union[str, Path, io.BytesIO, Tuple[Union[str, Path], io.BytesIO]]]) -> None: """paths setter""" self.__paths = paths
[docs] @abstractmethod def get_scannable_files(self, config: Config) -> Sequence[ContentProvider]: """Get list of file object for analysis based on attribute "paths". Args: config: dict of credsweeper configuration Return: file objects to analyse """ raise NotImplementedError()