httpx/httpcore/structures.py
Tom Christie 8a29a0a1ad Rollin'
2019-04-26 17:00:47 +01:00

21 lines
566 B
Python

import typing
class LookupDict(dict):
"""Dictionary lookup object."""
def __init__(self, name: str = None) -> None:
self.name = name
super(LookupDict, self).__init__()
def __repr__(self) -> str:
return "<lookup '%s'>" % (self.name)
def __getitem__(self, key: typing.Any) -> typing.Any:
# We allow fall-through here, so values default to None
return self.__dict__.get(key, None)
def get(self, key: typing.Any, default: typing.Any = None) -> typing.Any:
return self.__dict__.get(key, default)