pypicloud.cache.base module¶
Base class for all cache implementations
- class pypicloud.cache.base.ICache(request=None, storage=None, allow_overwrite=None, calculate_hashes=True, allow_delete=True)[source]¶
Bases:
object
Base class for a caching database that stores package metadata
- all(name: str) List[Package] [source]¶
Search for all versions of a package
- Parameters
- namestr
The name of the package
- Returns
- packageslist
List of all
Package
s with the given name
- check_health() Tuple[bool, str] [source]¶
Check the health of the cache backend
- Returns
- (healthy, status)(bool, str)
Tuple that describes the health status and provides an optional status message
- clear(package: Package) None [source]¶
Remove this package from the caching database
- Parameters
- package
Package
- package
- delete(package: Package) None [source]¶
Delete this package from the database and from storage
- Parameters
- package
Package
- package
- distinct() List[str] [source]¶
Get all distinct package names
- Returns
- nameslist
List of package names
- fetch(filename: str) Package [source]¶
Get matching package if it exists
- Parameters
- filenamestr
Name of the package file
- Returns
- package
Package
- package
- get_url(package: Package) str [source]¶
Get the download url for a package
- Parameters
- package
Package
- package
- Returns
- urlstr
- reload_from_storage(clear: bool = True) None [source]¶
Make sure local database is populated with packages
- reload_if_needed() None [source]¶
Reload packages from storage backend if cache is empty
This will be called when the server first starts
- search(criteria: Dict[str, List[str]], query_type: str) List[Package] [source]¶
Perform a search from pip
- Parameters
- criteriadict
Dictionary containing the search criteria. Pip sends search criteria for “name” and “summary” (typically, both of these lists have the same search values).
Example:
{ "name": ["value1", "value2", ..., "valueN"], "summary": ["value1", "value2", ..., "valueN"] }
- query_typestr
Type of query to perform. By default, pip sends “or”.
- summary() List[Dict[str, Any]] [source]¶
Summarize package metadata
- Returns
- packageslist
List of package dicts, each of which contains ‘name’, ‘summary’, and ‘last_modified’.
- upload(filename: str, data: BinaryIO, name: Optional[str] = None, version: Optional[str] = None, summary: Optional[str] = None, requires_python: Optional[str] = None) Package [source]¶
Save this package to the storage mechanism and to the cache
- Parameters
- filenamestr
Name of the package file
- datafile
File-like readable object
- namestr, optional
The name of the package (if not provided, will be parsed from filename)
- versionstr, optional
The version number of the package (if not provided, will be parsed from filename)
- summarystr, optional
The summary of the package
- requires_pythonstr, optional
The Python version requirement
- Returns
- package
Package
The Package object that was uploaded
- package
- Raises
- eValueError
If the package already exists and allow_overwrite = False