def retrieve_logical(bytes, fielddef, *ignore):
"""
Returns True if bytes is 't', 'T', 'y', or 'Y'
None if '?'
False otherwise
"""
cls = fielddef[CLASS]
empty = fielddef[EMPTY]
bytes = bytes.tostring()
if bytes in 'tTyY':
return cls(True)
elif bytes in 'fFnN':
return cls(False)
elif bytes in '? ':
if empty is NoneType:
return None
return empty()
elif LOGICAL_BAD_IS_NONE:
return None
else:
raise BadDataError('Logical field contained %r' % bytes)
return typ(bytes)
评论列表
文章目录