Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
Cache Class Reference
Inheritance diagram for Cache:

Public Member Functions

None __init__ (self, str cache_dir)
 
str get_path_for_link (self, Link link)
 
Link get (self, Link link, Optional[str] package_name, List[Tag] supported_tags)
 

Data Fields

 cache_dir
 

Protected Member Functions

List[str] _get_cache_path_parts (self, Link link)
 
List[Any] _get_candidates (self, Link link, str canonical_package_name)
 

Detailed Description

An abstract class - provides cache directories for data from links

:param cache_dir: The root of the cache.

Definition at line 32 of file cache.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ (   self,
str  cache_dir 
)

Reimplemented in EphemWheelCache, SimpleWheelCache, and WheelCache.

Definition at line 38 of file cache.py.

38 def __init__(self, cache_dir: str) -> None:
39 super().__init__()
40 assert not cache_dir or os.path.isabs(cache_dir)
41 self.cache_dir = cache_dir or None
42
for i

References Cache.__init__(), and i.

Referenced by Cache.__init__(), and Protocol.__init_subclass__().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ _get_cache_path_parts()

List[str] _get_cache_path_parts (   self,
Link  link 
)
protected
Get parts of part that must be os.path.joined with cache_dir

Definition at line 43 of file cache.py.

43 def _get_cache_path_parts(self, link: Link) -> List[str]:
44 """Get parts of part that must be os.path.joined with cache_dir"""
45
46 # We want to generate an url to use as our cache key, we don't want to
47 # just re-use the URL because it might have other items in the fragment
48 # and we don't care about those.
49 key_parts = {"url": link.url_without_fragment}
50 if link.hash_name is not None and link.hash is not None:
51 key_parts[link.hash_name] = link.hash
52 if link.subdirectory_fragment:
53 key_parts["subdirectory"] = link.subdirectory_fragment
54
55 # Include interpreter name, major and minor version in cache key
56 # to cope with ill-behaved sdists that build a different wheel
57 # depending on the python version their setup.py is being run on,
58 # and don't encode the difference in compatibility tags.
59 # https://github.com/pypa/pip/issues/7296
60 key_parts["interpreter_name"] = interpreter_name()
61 key_parts["interpreter_version"] = interpreter_version()
62
63 # Encode our key url with sha224, we'll use this because it has similar
64 # security properties to sha256, but with a shorter total output (and
65 # thus less secure). However the differences don't make a lot of
66 # difference for our use case here.
67 hashed = _hash_dict(key_parts)
68
69 # We want to nest the directories some to prevent having a ton of top
70 # level directories where we might run out of sub directories on some
71 # FS.
72 parts = [hashed[:2], hashed[2:4], hashed[4:6], hashed[6:]]
73
74 return parts
75

◆ _get_candidates()

List[Any] _get_candidates (   self,
Link  link,
str  canonical_package_name 
)
protected

Definition at line 76 of file cache.py.

76 def _get_candidates(self, link: Link, canonical_package_name: str) -> List[Any]:
77 can_not_cache = not self.cache_dir or not canonical_package_name or not link
78 if can_not_cache:
79 return []
80
81 candidates = []
82 path = self.get_path_for_link(link)
83 if os.path.isdir(path):
84 for candidate in os.listdir(path):
85 candidates.append((candidate, path))
86 return candidates
87

◆ get()

Link get (   self,
Link  link,
Optional[str]  package_name,
List[Tag supported_tags 
)
Returns a link to a cached item if it exists, otherwise returns the
passed link.

Reimplemented in SimpleWheelCache, and WheelCache.

Definition at line 92 of file cache.py.

97 ) -> Link:
98 """Returns a link to a cached item if it exists, otherwise returns the
99 passed link.
100 """
101 raise NotImplementedError()
102
103

Referenced by LegacyMetadata.__getitem__(), Layout.__getitem__(), LegacyMetadata.check(), ThemeStack.push_theme(), and LegacyMetadata.write_file().

Here is the caller graph for this function:

◆ get_path_for_link()

str get_path_for_link (   self,
Link  link 
)
Return a directory to store cached items in for link.

Reimplemented in SimpleWheelCache, and WheelCache.

Definition at line 88 of file cache.py.

88 def get_path_for_link(self, link: Link) -> str:
89 """Return a directory to store cached items in for link."""
91

Field Documentation

◆ cache_dir

cache_dir

Definition at line 41 of file cache.py.


The documentation for this class was generated from the following file: