pypicloud.util module


class pypicloud.util.BetterScrapingLocator(*args, **kw)[source]

Bases: distlib.locators.SimpleScrapingLocator

Layer on top of SimpleScrapingLocator that allows preferring wheels

locate(requirement, prereleases=False, wheel=True)[source]
prefer_wheel = True[source]
class pypicloud.util.TimedCache(cache_time, factory=None)[source]

Bases: dict

Dict that will store entries for a given time, then evict them


cache_time : int or None

The amount of time to cache entries for, in seconds. 0 will not cache. None will cache forever.

factory : callable, optional

If provided, when the TimedCache is accessed and has no value, it will attempt to populate itself by calling this function with the key it was accessed with. This function should return a value to cache, or None if no value is found.

get(key, default=None)[source]
set_expire(key, value, expiration)[source]

Set a value in the cache with a specific expiration


key : str

value : value

expiration : int or None

Sets the value to expire this many seconds from now. If None, will never expire.

pypicloud.util.create_matcher(queries, query_type)[source]

Create a matcher for a list of queries


queries : list

List of queries

query_type: str

Type of query to run: [“or”|”and”]


Matcher function

pypicloud.util.get_settings(settings, prefix, **kwargs)[source]

Convenience method for fetching settings

Returns a dict; any settings that were missing from the config file will not be present in the returned dict (as opposed to being present with a None value)


settings : dict

The settings dict

prefix : str

String to prefix all keys with when fetching value from settings

**kwargs : dict

Mapping of setting name to conversion function (e.g. str or asbool)

pypicloud.util.is_compatible(wheel, tags=None)[source]

Hacked function to monkey patch into distlib


Normalize a python package name

pypicloud.util.parse_filename(filename, name=None)[source]

Parse a name and version out of a filename