MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _get_base_path

Method _get_base_path

lib/matplotlib/texmanager.py:169–185  ·  view source on GitHub ↗

Return a file path based on a hash of the string, fontsize, and dpi.

(cls, tex, fontsize, dpi=None)

Source from the content-addressed store, hash-verified

167
168 @classmethod
169 def _get_base_path(cls, tex, fontsize, dpi=None):
170 """
171 Return a file path based on a hash of the string, fontsize, and dpi.
172 """
173 src = cls._get_tex_source(tex, fontsize) + str(dpi)
174 filehash = hashlib.sha256(
175 src.encode('utf-8'),
176 usedforsecurity=False
177 ).hexdigest()
178 filepath = cls._cache_dir
179
180 num_letters, num_levels = 2, 2
181 for i in range(0, num_letters*num_levels, num_letters):
182 filepath = filepath / filehash[i:i+2]
183
184 filepath.mkdir(parents=True, exist_ok=True)
185 return filepath / filehash
186
187 @classmethod
188 def get_basefile(cls, tex, fontsize, dpi=None): # Kept for backcompat.

Callers 4

get_basefileMethod · 0.80
make_texMethod · 0.80
make_dviMethod · 0.80
make_pngMethod · 0.80

Calls 1

_get_tex_sourceMethod · 0.80

Tested by

no test coverage detected