pypicloud.cache.base module

Base class for all cache implementations

class pypicloud.cache.base.ICache(request=None, storage=None, calculate_hashes=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
packagePackage
clear_all() None[source]

Clear all cached packages from the database

classmethod configure(settings)[source]

Configure the cache method with app settings

delete(package: Package) None[source]

Delete this package from the database and from storage

Parameters
packagePackage
Raises
eValueError

If user is unauthorized for delete

distinct() List[str][source]

Get all distinct package names

Returns
nameslist

List of package names

download_response(package: Package)[source]

Pass through to storage

fetch(filename: str) Package[source]

Get matching package if it exists

Parameters
filenamestr

Name of the package file

Returns
packagePackage
get_url(package: Package) str[source]

Get the download url for a package

Parameters
packagePackage
Returns
urlstr
new_package(*args, **kwargs) Package[source]
classmethod postfork(**kwargs)[source]

This method will be called after uWSGI forks

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

save(package: Package) None[source]

Save this package to the database

Parameters
packagePackage
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, **metadata) 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
packagePackage

The Package object that was uploaded

Raises
eValueError

If the package already exists and user is unauthorized for overwrites