utils Package

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

Classes

CaseInsensitiveDict

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

Enums

CaseInsensitiveEnumMeta

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'

Functions

case_insensitive_dict

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

case_insensitive_dict(*args: Mapping[str, Any] | Iterable[Tuple[str, Any]] | None, **kwargs: Any) -> MutableMapping[str, Any]

Parameters

Name Description
args
Required

The positional arguments to pass to the dict.

Returns

Type Description

A case-insensitive mutable mapping object.