Source code for eve_panel.types
import param
from bson import objectid
[docs]class CoerceClassSelector(param.ClassSelector):
def __set__(self, obj, val):
try:
val = self.class_(val)
except:
pass
super().__set__(obj, val)
[docs]def objectid_param(**kwargs):
return CoerceClassSelector(str, constant=True, **kwargs)
[docs]def bytes_param(**kwargs):
return param.ClassSelector(bytes, **kwargs)
[docs]def set_param(**kwargs):
return param.ClassSelector(set, **kwargs)
TYPE_MAPPING = {
"objectid": objectid_param,
"boolean": param.Boolean,
"binary": bytes_param,
"date": param.Date,
"datetime": param.Date,
"dict": param.Dict,
"float": param.Number,
"integer": param.Integer,
"list": param.List,
"number": param.Number,
"set": set_param,
"string": param.String,
"media": bytes_param,
}