ckan_api_client.utils
-
class ckan_api_client.utils.IDPair[source]
Bases: ckan_api_client.utils.IDPair
A pair (named tuple) mapping a “source” id with the one used
internally in Ckan.
This is mostly used associated with IDMap.
Keys: source_id, ckan_id
-
class ckan_api_client.utils.SuppressExceptionIf(cond)[source]
Bases: object
Context manager used to suppress exceptions if they match
a given condition.
Usage example:
is_404 = lambda x: isinstance(x, HTTPError) and x.status_code == 404
with SuppressExceptionIf(is_404):
client.request(...)
-
class ckan_api_client.utils.IDMap[source]
Bases: object
Two-way hashmap to map source ids to ckan ids
and the other way back.
-
to_ckan(source_id)[source]
Convert a source id to ckan id
-
to_source(ckan_id)[source]
Convert a ckan id to source id
-
add(pair)[source]
Add a new id pair
Parameters: | pair (IDPair) – the id pair to be added |
Raises ValueError: |
| if one of the two ids is found in a mismatching pair |
-
remove(pair)[source]
Remove an id pair.
Parameters: | pair (IDPair) – the id pair to be removed |
Raises ValueError: |
| if one of the two ids is found in a mismatching pair |
-
class ckan_api_client.utils.FrozenDict(*a, **kw)[source]
Bases: _abcoll.MutableMapping
Frozen dictionary.
Acts as a read-only dictionary, preventing changes
and returning frozen objects when asked for values.
-
class ckan_api_client.utils.FrozenSequence(data)[source]
Bases: _abcoll.Sequence
Base class for the FrozenList/FrozenTuple classes.
Acts as a read-only sequence type, returning frozen
versions of mutable objects.
-
class ckan_api_client.utils.FrozenList(data)[source]
Bases: ckan_api_client.utils.FrozenSequence
Immutable list-like.
-
class ckan_api_client.utils.FrozenTuple(data)[source]
Bases: ckan_api_client.utils.FrozenSequence
Immutable tuple-like.
-
ckan_api_client.utils.freeze(obj)[source]
Returns the “frozen” version of a mutable type.
Raises TypeError: |
| if a frozen version for that object doesn’t exist |
-
class ckan_api_client.utils.WrappedList(*a, **kw)[source]
Bases: _abcoll.MutableSequence
-
insert(pos, item)[source]