MCPcopy Create free account
hub / github.com/psf/cachecontrol / __init__

Method __init__

cachecontrol/caches/file_cache.py:25–52  ·  view source on GitHub ↗
(
        self,
        directory: str | Path,
        forever: bool = False,
        filemode: int = 0o0600,
        dirmode: int = 0o0700,
        lock_class: type[BaseFileLock] | None = None,
    )

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected