

def _db_get_value(self, v, p):
    if v.has_stringvalue():
        sval = v.stringvalue()
        meaning = p.meaning()
        if (meaning == entity_pb.Property.BLOBKEY):
            sval = BlobKey(sval)
        elif (meaning == entity_pb.Property.BLOB):
            if (p.meaning_uri() == _MEANING_URI_COMPRESSED):
                sval = _CompressedValue(sval)
        elif (meaning == entity_pb.Property.ENTITY_PROTO):
            pb = entity_pb.EntityProto()
            pb.MergePartialFromString(sval)
            modelclass = Expando
            if pb.key().path().element_size():
                kind = pb.key().path().element((- 1)).type()
                modelclass = Model._kind_map.get(kind, modelclass)
            sval = modelclass._from_pb(pb)
        elif (meaning != entity_pb.Property.BYTESTRING):
            try:
                sval.decode('ascii')
            except UnicodeDecodeError:
                try:
                    sval = unicode(sval.decode('utf-8'))
                except UnicodeDecodeError:
                    pass
        return sval
    elif v.has_int64value():
        ival = v.int64value()
        if (p.meaning() == entity_pb.Property.GD_WHEN):
            return (_EPOCH + datetime.timedelta(microseconds=ival))
        return ival
    elif v.has_booleanvalue():
        return bool(v.booleanvalue())
    elif v.has_doublevalue():
        return v.doublevalue()
    elif v.has_referencevalue():
        rv = v.referencevalue()
        app = rv.app()
        namespace = rv.name_space()
        pairs = [(elem.type(), (elem.id() or elem.name())) for elem in rv.pathelement_list()]
        return Key(pairs=pairs, app=app, namespace=namespace)
    elif pb.has_pointvalue():
        pv = v.pointvalue()
        return GeoPt(pv.x(), pv.y())
    elif v.has_uservalue():
        return _unpack_user(v)
    else:
        return None

dataset/ETHPy150Open GoogleCloudPlatform/datastore-ndb-python/ndb/model.py GenericProperty._db_get_value/VarMisuse@428/549 `v`->`pb`