(
self,
directory: str | Path,
forever: bool = False,
filemode: int = 0o0600,
dirmode: int = 0o0700,
lock_class: type[BaseFileLock] | None = None,
)
| 23 | """Shared implementation for both FileCache variants.""" |
| 24 | |
| 25 | def __init__( |
| 26 | self, |
| 27 | directory: str | Path, |
| 28 | forever: bool = False, |
| 29 | filemode: int = 0o0600, |
| 30 | dirmode: int = 0o0700, |
| 31 | lock_class: type[BaseFileLock] | None = None, |
| 32 | ) -> None: |
| 33 | try: |
| 34 | if lock_class is None: |
| 35 | from filelock import FileLock |
| 36 | |
| 37 | lock_class = FileLock |
| 38 | except ImportError: |
| 39 | notice = dedent( |
| 40 | """ |
| 41 | NOTE: In order to use the FileCache you must have |
| 42 | filelock installed. You can install it via pip: |
| 43 | pip install cachecontrol[filecache] |
| 44 | """ |
| 45 | ) |
| 46 | raise ImportError(notice) |
| 47 | |
| 48 | self.directory = directory |
| 49 | self.forever = forever |
| 50 | self.filemode = filemode |
| 51 | self.dirmode = dirmode |
| 52 | self.lock_class = lock_class |
| 53 | |
| 54 | @staticmethod |
| 55 | def encode(x: str) -> str: |
nothing calls this directly
no outgoing calls
no test coverage detected