labpack/databases/google/datastore.py
def _prepare_record(self, record):

        ''' a helper method for converting a record to column-based fields '''

        fields = {}
        for key, value in self.model.keyMap.items():
            record_key = key[1:]
            if record_key:
                if self.item_key.findall(record_key):
                    pass
                else:
                    if value['value_datatype'] in ('boolean', 'string', 'number'):
                        try:
                            results = self.model._walk(key, record)
                            fields[record_key] = results[0]
                        except:
                            if self.default_values:
                                results = self.model._walk(key, self.default)
                                fields[record_key] = results[0]
                    elif value['value_datatype'] == 'list' and record_key in self.json_lists:
                        try:
                            results = self.model._walk(key, record)
                            fields[record_key] = json.dumps(results[0])
                        except:
                            if self.default_values:
                                results = self.model._walk(key, self.default)
                                fields[record_key] = json.dumps(results[0])
                    elif value['value_datatype'] == 'list':
                        try:
                            results = self.model._walk(key, record)
                            fields[record_key] = results[0]
                        except:
                            if self.default_values:
                                results = self.model._walk(key, self.default)
                                fields[record_key] = results[0]
                    elif key in self.empty_maps:
                        try:
                            results = self.model._walk(key, record)
                            fields[record_key] = json.dumps(results[0])
                        except:
                            if self.default_values:
                                fields[record_key] = json.dumps({})

        # add id field if missing
        uid = self.labID().id24
        if not 'id' in fields.keys():
            if '.id' in self.model.keyMap.keys():
                if self.model.keyMap['.id']['value_datatype'] == 'number':
                    integer = False
                    if 'integer_data' in self.model.keyMap['.id'].keys():
                        if self.model.keyMap['.id']['integer_data']:
                            fields['id'] = 0
                            integer = True
                    if not integer:
                        fields['id'] = 0.0
                else:
                    fields['id'] = uid
            else:
                fields['id'] = uid

        return fields
 a helper method for converting a record to column-based fields 
a helper method for converting a record to column-based fields
a helper method for converting a record to column - based fields
def _prepare_record(self, record):
        fields = {}
        for key, value in self.model.keyMap.items():
            record_key = key[1:]
            if record_key:
                if self.item_key.findall(record_key):
                    pass
                else:
                    if value['value_datatype'] in ('boolean', 'string', 'number'):
                        try:
                            results = self.model._walk(key, record)
                            fields[record_key] = results[0]
                        except:
                            if self.default_values:
                                results = self.model._walk(key, self.default)
                                fields[record_key] = results[0]
                    elif value['value_datatype'] == 'list' and record_key in self.json_lists:
                        try:
                            results = self.model._walk(key, record)
                            fields[record_key] = json.dumps(results[0])
                        except:
                            if self.default_values:
                                results = self.model._walk(key, self.default)
                                fields[record_key] = json.dumps(results[0])
                    elif value['value_datatype'] == 'list':
                        try:
                            results = self.model._walk(key, record)
                            fields[record_key] = results[0]
                        except:
                            if self.default_values:
                                results = self.model._walk(key, self.default)
                                fields[record_key] = results[0]
                    elif key in self.empty_maps:
                        try:
                            results = self.model._walk(key, record)
                            fields[record_key] = json.dumps(results[0])
                        except:
                            if self.default_values:
                                fields[record_key] = json.dumps({})
        uid = self.labID().id24
        if not 'id' in fields.keys():
            if '.id' in self.model.keyMap.keys():
                if self.model.keyMap['.id']['value_datatype'] == 'number':
                    integer = False
                    if 'integer_data' in self.model.keyMap['.id'].keys():
                        if self.model.keyMap['.id']['integer_data']:
                            fields['id'] = 0
                            integer = True
                    if not integer:
                        fields['id'] = 0.0
                else:
                    fields['id'] = uid
            else:
                fields['id'] = uid
        return fields
def _prepare_record ( self , record ) : fields = { } for key , value in self . model . keyMap . items ( ) : record_key = key [ 1 : ] if record_key : if self . item_key . findall ( record_key ) : pass else : if value [ 'value_datatype' ] in ( 'boolean' , 'string' , 'number' ) : try : results = self . model . _walk ( key , record ) fields [ record_key ] = results [ 0 ] except : if self . default_values : results = self . model . _walk ( key , self . default ) fields [ record_key ] = results [ 0 ] elif value [ 'value_datatype' ] == 'list' and record_key in self . json_lists : try : results = self . model . _walk ( key , record ) fields [ record_key ] = json . dumps ( results [ 0 ] ) except : if self . default_values : results = self . model . _walk ( key , self . default ) fields [ record_key ] = json . dumps ( results [ 0 ] ) elif value [ 'value_datatype' ] == 'list' : try : results = self . model . _walk ( key , record ) fields [ record_key ] = results [ 0 ] except : if self . default_values : results = self . model . _walk ( key , self . default ) fields [ record_key ] = results [ 0 ] elif key in self . empty_maps : try : results = self . model . _walk ( key , record ) fields [ record_key ] = json . dumps ( results [ 0 ] ) except : if self . default_values : fields [ record_key ] = json . dumps ( { } ) uid = self . labID ( ) . id24 if not 'id' in fields . keys ( ) : if '.id' in self . model . keyMap . keys ( ) : if self . model . keyMap [ '.id' ] [ 'value_datatype' ] == 'number' : integer = False if 'integer_data' in self . model . keyMap [ '.id' ] . keys ( ) : if self . model . keyMap [ '.id' ] [ 'integer_data' ] : fields [ 'id' ] = 0 integer = True if not integer : fields [ 'id' ] = 0.0 else : fields [ 'id' ] = uid else : fields [ 'id' ] = uid return fields
a helper method for converting a record to column-based fields
a helper method for converting a record to column - based fields
''' a helper method for converting a record to column-based fields ''' # add id field if missing
self
record