pypicloud.util module¶
Utilities
- class pypicloud.util.EnvironSettings(settings: Dict[str, Any], env: Optional[Dict[str, str]] = None)[source]¶
Bases:
object
- clone() EnvironSettings [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)
- Parameters
- prefixstr
String to prefix all keys with when fetching value from settings
- **kwargsdict
Mapping of setting name to conversion function (e.g. str or asbool)
- 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
- Parameters
- 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.
- pypicloud.util.create_matcher(queries: List[str], query_type: str) Callable[[str], bool] [source]¶
Create a matcher for a list of queries
- Parameters
- querieslist
List of queries
- query_type: str
Type of query to run: [“or”|”and”]
- Returns
- Matcher function
- 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