Validate that a given new pk to set is always set to None, then return
        a new pk
972873
def _validate(self, value):
        
        if value is not None:
            raise ValueError('The pk for %s is "auto-increment", you must not fill it' %
                            self._model.__name__)
        key = self._instance.make_key(self._model._name, 'max_pk')
        return self.normalize(self.connection.incr(key))
270809
public static <K, V> void validateNotNull(K key, V value) {
        checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
        checkNotNull(value, NULL_VALUE_IS_NOT_ALLOWED);
    }
1073192
def t_insert_dict_if_new(self, tblname, d, PKfields, fields=None):
        ''''''
        SQL, values = self._insert_dict_if_new_inner(tblname, d, PKfields, fields=fields)
        if SQL != False:
            self.execute_select(SQL, parameters=values, locked=True)
            return True, d
        return False, values
482341
def _validate_mandatory_keys(mandatory, validated, data, to_validate):
    """"""
    errors = []
    for key, sub_schema in mandatory.items():
        if key not in data:
            errors.append('missing key: %r' % (key,))
            continue
        try:
            validated[key] = sub_schema(data[key])
        except NotValid as ex:
            errors.extend(['%r: %s' % (key, arg) for arg in ex.args])
        to_validate.remove(key)
    return errors
530979
def validate_transaction(self, tx, current_transactions=[]):
        """"""

        transaction = tx

        # CLEANUP: The conditional below checks for transaction in dict format.
        # It would be better to only have a single format for the transaction
        # throught the code base.
        if isinstance(transaction, dict):
            try:
                transaction = Transaction.from_dict(tx)
            except SchemaValidationError as e:
                logger.warning('Invalid transaction schema: %s', e.__cause__.message)
                return False
            except ValidationError as e:
                logger.warning('Invalid transaction (%s): %s', type(e).__name__, e)
                return False
        return transaction.validate(self, current_transactions)
810429
def _none():
    """"""

    Mock = type("Mock", (), {"__getattr__": lambda Qt, attr: None})

    Qt.__binding__ = "None"
    Qt.__qt_version__ = "0.0.0"
    Qt.__binding_version__ = "0.0.0"
    Qt.QtCompat.loadUi = lambda uifile, baseinstance=None: None
    Qt.QtCompat.setSectionResizeMode = lambda *args, **kwargs: None

    for submodule in _common_members.keys():
        setattr(Qt, submodule, Mock())
        setattr(Qt, "_" + submodule, Mock())
240131
def setdefault (self, key, *args):
        """"""
        assert isinstance(key, basestring)
        return dict.setdefault(self, key.lower(), *args)
293600
def setIfMissing(self, key, value):
        """"""
        if self.get(key) is None:
            self.set(key, value)
        return self
958178
def set(self, key, value, *, expire=0, pexpire=0, exist=None):
        
        if expire and not isinstance(expire, int):
            raise TypeError("expire argument must be int")
        if pexpire and not isinstance(pexpire, int):
            raise TypeError("pexpire argument must be int")

        args = []
        if expire:
            args[:] = [b'EX', expire]
        if pexpire:
            args[:] = [b'PX', pexpire]

        if exist is self.SET_IF_EXIST:
            args.append(b'XX')
        elif exist is self.SET_IF_NOT_EXIST:
            args.append(b'NX')
        fut = self.execute(b'SET', key, value, *args)
        return wait_ok(fut)
929395
def validate(self, value, model_instance):
        """"""
        # raise validation error if the use of this field says it can't be blank but it is
        if not self.blank and value is self.Empty:
            raise ValidationError(self.error_messages['blank'])
        else:
            return super(OpaqueKeyField, self).validate(value, model_instance)
72347
def checkAndCreate(self, key, payload):
        
        if key not in self:
            self[key] = payload
        return self[key]['id']
53957
def set(self, val, default=False, imported=False):
        
        if hasattr(self.validator, '__call__'):
            try:
                val = self.validator(val)
            except Exception as exc:
                raise type(exc)(
                    'Could not validate value for "%s" setting: %s' %
                    (self.name, exc)
                ) from None
        self.value = val
        self.imported = imported
        if default:
            self.default = val
        self.modified = True
284165
def validate_spec(self, key, value):
        """"""
        if self.spec and self.spec != value:
            raise OAISetSpecUpdateError("Updating spec is not allowed.")
        return value
237641
def validate_to_one(self, value):
        

        if value.rid and self.typeness is int:
            validators.validate_int(value)

        if value.rid and not self.skip_exists:
            if not value.load():
                raise ValidationError(self.messages['exists'])
        return value
361771
def update(cls, spec, updates, upsert=False):
        '''
        
        '''
        if 'key' in spec:
            previous = cls.get(spec['key'])
        else:
            previous = None
        if previous:
            # Update existing data.
            current = cls(**previous.__dict__)
        elif upsert:
            # Create new data.
            current = cls(**spec)
        else:
            current = None
        # XXX Should there be any error thrown if this is a noop?
        if current:
            current.__dict__.update(updates)
            current.save()
        return current
595919
def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
      unless pk and sequence
        default_pk, default_sequence = pk_and_sequence_for(table)
        pk ||= default_pk
        sequence ||= default_sequence
      end
      if pk
        if sequence
          quoted_sequence = quote_column_name(sequence)

          select_value <<-end_sql, 'Reset sequence'
              SELECT setval('#{quoted_sequence}', (SELECT COALESCE(MAX(#{quote_column_name pk})+(SELECT increment_by FROM #{quoted_sequence}), (SELECT min_value FROM #{quoted_sequence})) FROM #{quote_table_name(table)}), false)
            end_sql
        else
          @logger.warn "#{table} has primary key #{pk} with no default sequence" if @logger
        end
      end
    end
1345602
def validate(self, name, value):
        """"""

        if self.valid_set and value not in self.valid_set:
            raise ImproperlyConfigured(
                "%s: \"%s\" is not a valid setting (choose between %s)." %
                (name, value, ", ".join("\"%s\"" % x for x in self.valid_set)))

        return value