pypicloud.util module


class pypicloud.util.EnvironSettings(settings: Dict[str, Any], env: Optional[Dict[str, str]] = None)[source]

Bases: object

clone() EnvironSettings[source]
get(key: str, default: Optional[Any] = None) Any[source]
get_as_dict(prefix: str, **kwargs: Callable[[Any], Any]) Dict[str, Any][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)


String to prefix all keys with when fetching value from settings


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

items() ItemsView[str, Any][source]
keys() KeysView[str][source]
pop(key: str, default: ~typing.Any = <object object>) Any[source]
read_prefix_from_environ(prefix: str) None[source]
setdefault(key: str, value: Any) Any[source]
exception pypicloud.util.PackageParseError[source]

Bases: ValueError

class pypicloud.util.TimedCache(cache_time: Optional[int], factory: Optional[Callable[[Any], Any]] = None)[source]

Bases: dict

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

cache_timeint or None

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

factorycallable, 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]

Return the value for key if key is in the dictionary, else default.

set_expire(key, value, expiration)[source]

Set a value in the cache with a specific expiration

expirationint or None

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

pypicloud.util.create_matcher(queries: List[str], query_type: str) Callable[[str], bool][source]

Create a matcher for a list of queries


List of queries

query_type: str

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

Matcher function
pypicloud.util.get_packagetype(name: str) str[source]

Get package type out of a filename

pypicloud.util.normalize_metadata(metadata: Dict[str, Union[str, bytes]]) Dict[str, str][source]

Strip non-ASCII characters from metadata values and replace “_” in metadata keys to “-”

pypicloud.util.normalize_metadata_value(value: Union[str, bytes]) str[source]

Strip non-ASCII characters from metadata values

pypicloud.util.normalize_name(name: str) str[source]

Normalize a python package name

pypicloud.util.parse_filename(filename: str, name: Optional[str] = None) Tuple[str, str][source]

Parse a name and version out of a filename