corehttp.utils package

This utils module provides functionality that is intended to be used by developers building on top of the core package.

class corehttp.utils.CaseInsensitiveDict(data: Mapping[str, Any] | Iterable[Tuple[str, Any]] | None = None, **kwargs: Any)[source]

NOTE: This implementation is heavily inspired from the case insensitive dictionary from the requests library. Thank you !! Case insensitive dictionary implementation. The keys are expected to be strings and will be stored in lower case. case_insensitive_dict = CaseInsensitiveDict() case_insensitive_dict[‘Key’] = ‘some_value’ case_insensitive_dict[‘key’] == ‘some_value’ #True

Parameters:

data (Mapping[str, Any] or Iterable[Tuple[str, Any]]) – Initial data to store in the dictionary.

clear() None.  Remove all items from D.
copy() CaseInsensitiveDict[source]
get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
lowerkey_items() Iterator[Tuple[str, Any]][source]
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values
class corehttp.utils.CaseInsensitiveEnumMeta(cls, bases, classdict, *, boundary=None, _simple=False, **kwds)[source]

Enum metaclass to allow for interoperability with case-insensitive strings.

Consuming this metaclass in an SDK should be done in the following manner:

from enum import Enum
from corehttp.utils import CaseInsensitiveEnumMeta

class MyCustomEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
    FOO = 'foo'
    BAR = 'bar'
mro()

Return a type’s method resolution order.

corehttp.utils.case_insensitive_dict(*args: Mapping[str, Any] | Iterable[Tuple[str, Any]] | None, **kwargs: Any) MutableMapping[str, Any][source]

Return a case-insensitive mutable mapping from an inputted mapping structure.

Parameters:

args (Mapping[str, Any] or Iterable[Tuple[str, Any]) – The positional arguments to pass to the dict.

Returns:

A case-insensitive mutable mapping object.

Return type:

MutableMapping