2023-04-12 09:50:54 +08:00
|
|
|
convfuncs = {
|
|
|
|
'int':int,
|
|
|
|
'long':int,
|
|
|
|
'llong':int,
|
|
|
|
'float':float,
|
|
|
|
'double':float,
|
|
|
|
'date':str,
|
|
|
|
'datetime':str,
|
|
|
|
'ddouble':float
|
|
|
|
}
|
|
|
|
|
|
|
|
def conv(info, name, value):
|
|
|
|
fields = info['fields']
|
|
|
|
for f in fields:
|
|
|
|
if f['name'] == name:
|
|
|
|
f = convfuncs.get(f['type'], None)
|
2023-05-11 16:43:14 +08:00
|
|
|
if f is None or value is None:
|
2023-04-12 09:50:54 +08:00
|
|
|
return value
|
|
|
|
return f(value)
|
|
|
|
return value
|
|
|
|
|
|
|
|
def convrec(info, ns):
|
|
|
|
ret = {k:conv(info, k, v) for k,v in ns.items()}
|
|
|
|
return ret
|
|
|
|
|