def get_field(name, data, default="<STR_LIT:object>", document_object_field=None, is_document=False):
if isinstance(data, AbstractField):<EOL><INDENT>return data<EOL><DEDENT>data = keys_to_string(data)<EOL>_type = data.get('<STR_LIT:type>', default)<EOL>if _type == "<STR_LIT:string>":<EOL><INDENT>return StringField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return BinaryField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return BooleanField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return ByteField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return ShortField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return IntegerField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return LongField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT:float>":<EOL><INDENT>return FloatField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return DoubleField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return IpField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT:date>":<EOL><INDENT>return DateField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return MultiField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return GeoPointField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return AttachmentField(name=name, **data)<EOL><DEDENT>elif is_document or _type == "<STR_LIT>":<EOL><INDENT>if document_object_field:<EOL><INDENT>return document_object_field(name=name, **data)<EOL><DEDENT>else:<EOL><INDENT>data.pop("<STR_LIT:name>",None)<EOL>return DocumentObjectField(name=name, **data)<EOL><DEDENT><DEDENT>elif _type == "<STR_LIT:object>":<EOL><INDENT>if '<STR_LIT>' in data or "<STR_LIT>" in data:<EOL><INDENT>if document_object_field:<EOL><INDENT>return document_object_field(name=name, **data)<EOL><DEDENT>else:<EOL><INDENT>return DocumentObjectField(name=name, **data)<EOL><DEDENT><DEDENT>return ObjectField(name=name, **data)<EOL><DEDENT>elif _type == "<STR_LIT>":<EOL><INDENT>return NestedObject(name=name, **data)<EOL><DEDENT>raise RuntimeError("<STR_LIT>" % _type)<EOL>
Return a valid Field by given data