Check whether the given parameter value is allowed.
        Log messages into ``self.result``.

        :param dict parameters: the given parameters
188931
def _check_allowed_values(self, parameters):
        
        for key, allowed_values in self.ALLOWED_VALUES:
            self.log([u"Checking allowed values for parameter '%s'", key])
            if key in parameters:
                value = parameters[key]
                if value not in allowed_values:
                    self._failed(u"Parameter '%s' has value '%s' which is not allowed." % (key, value))
                    return
        self.log(u"Passed")
1017375
def validate(self, *args, **kwargs): # pylint: disable=arguments-differ
        
        return super(ParameterValidator, self)._validate(*args, **kwargs)
234688
def print_values(self, parameter):
        
        if parameter in self.VALUES:
            self.print_info(u"Available values for parameter '%s':" % parameter)
            self.print_generic(u"\n".join(self.VALUES[parameter]))
            return self.HELP_EXIT_CODE
        if parameter not in [u"?", u""]:
            self.print_error(u"Invalid parameter name '%s'" % parameter)
        self.print_info(u"Parameters for which values can be listed:")
        self.print_generic(u"\n".join(sorted(self.VALUES.keys())))
        return self.HELP_EXIT_CODE
572899
def takes_parameters(count):
    """"""
    def decorator(f):
        """Decorate the supplied function with the "takes_parameters" logic."""
        @wraps(f)
        def wrapper(filter_operation_info, location, context, parameters, *args, **kwargs):
            """Check that the supplied number of parameters equals the expected number."""
            if len(parameters) != count:
                raise GraphQLCompilationError(u'Incorrect number of parameters, expected {} got '
                                              u'{}: {}'.format(count, len(parameters), parameters))

            return f(filter_operation_info, location, context, parameters, *args, **kwargs)

        return wrapper

    return decorator
567220
def set_parameters(self, parameter, value):
        
        if parameter == 'lo':
            self.parameters['lo'] = 1 / value
        else:
            self.parameters[parameter] = value
1114801
def check_output(params):
    
    popen = subprocess.Popen(params, shell=True, stderr=subprocess.STDOUT,
                             stdout=subprocess.PIPE)

    output, _ = popen.communicate()
    returncode = popen.poll()
    if returncode != 0:
        error = subprocess.CalledProcessError(returncode=returncode, cmd=params)
        error.output = output
        raise error
    return output
1166749
def check_ranged_param(ranged_param, allowed)
      🔞 = ranged_param.keys.map(&:to_sym) - allowed.map(&:to_sym)
      raise InvalidRangeException, "Attributes #{🔞.map(&:to_s).to_sentence} doesn't exists or aren't rangeables. Available ranges are: #{allowed.to_sentence}" if 🔞.any?
    end
92002
def __parameter_enum(self, param):
    
    if isinstance(param, messages.EnumField):
      return [enum_entry[0] for enum_entry in sorted(
          param.type.to_dict().items(), key=lambda v: v[1])]
831478
def validate(self, value, messages=None):
        
        valid     = True
        primitive = value

        def log(msg):
            if messages is not None:
                messages.append(msg)

        if self.enum:
            if value not in self.enum.keys():
                valid = False
                args  = (self.name, str(value))
                log("%s value '%s' not in allowed enumerated values." % args)
            else:
                primitive = int(self.enum[value])

        if self.type:
            if self.type.validate(primitive, messages, self.name) is False:
                valid = False

        if self.range:
            if primitive < self.range[0] or primitive > self.range[1]:
                valid = False
                args  = (self.name, str(primitive), self.range[0], self.range[1])
                log("%s value '%s' out of range [%d, %d]." % args)

        return valid
1330043
def check(self):
        
        for k in iter(self.__dict__.keys()):
            if k not in self.__allowed:
                raise TypeError("Parameter not allowed {}".format(k))

        for k in self.__requiered:
            if k not in self.__dict__:
                raise TypeError("Requiered parameter not found {}".format(k))

        if not isinstance(self.units, (int, float)):
            msg = "Unit must be either int or float, '{}'' found".format(
                type(self.units))
            raise TypeError(msg)

        if self.side not in self.__side:
            msg = "Side must be in {1}, '{0}' found".format(
                self.side, self.__side)
            raise TypeError(msg)

        if self.type not in self.__type:
            msg = "Type must be in {1}, '{0}' found".format(
                self.type, self.__type)
            raise TypeError(msg)

        if not self.type == "market" and (
           not hasattr(self, "expiry") or not hasattr(self, "price")):
            msg = "As type is {}, expiry and price must be provided".format(
                self.type)
            raise TypeError(msg)
        if hasattr(self, "expiry") and not isinstance(self.expiry, datetime):
            msg = "Expiry must be {1}, '{0}' found".format(
                type(self.expiry), datetime)
            raise TypeError(msg)

        if hasattr(self, "price"):
            try:
                Decimal(self.price)
            except InvalidOperation:
                msg = "Expiry must be int or float, '{0}' found".format(
                    type(self.price))
                raise TypeError(msg)

        return True
1289033
def is_valid_int_param(param):
    
    if param is None:
        return False
    try:
        param = int(param)
        if param < 0:
            return False
    except (TypeError, ValueError):
        return False
    return True
118910
def validate_path_parameters(target_path, api_path, path_parameters, context):
    
    base_path = context.get('basePath', '')
    full_api_path = re.sub(NORMALIZE_SLASH_REGEX, '/', base_path + api_path)
    parameter_values = get_path_parameter_values(
        target_path, full_api_path, path_parameters, context,
    )
    validate_parameters(parameter_values, path_parameters, context=context)
241361
def ratable_result(value, name, msgs):
    """"""
    return lambda w: Result(w, value, name, msgs)
1353922
def _check_ui_parameters(self):
        
        if isinstance(self.PARAMETER_UI_STUFF, dict):
            for param in self.PARAMETER_UI_STUFF.keys():
                # check parameter value can be found
                if not hasattr(self, param) and not hasattr(Task, param):
                    raise TaskValidationError('task "{}" defines parameter "{}" but a task attribute with that name '
                                              'could not be found'.format(self.NAME, param))

                # parameter cannot be None if not explicitly allowed
                if (getattr(self, param) is None
                    and (KEY_NONE_ALLOWED not in self.PARAMETER_UI_STUFF[param]
                         or not self.PARAMETER_UI_STUFF[param][KEY_NONE_ALLOWED])):
                    raise TaskValidationError('parameter "{}" is None and None is not explicitly allowed'
                                              ''.format(param))
1059470
def _EncodeParameters(self, parameters):
        

        if parameters is None:
            return None
        else:
            return urlencode(dict([(k, self._Encode(v)) for k, v in list(parameters.items()) if v is not None]))
967885
def result_or_error(response):
    
    data = response.json()
    result = data.get('result')
    if result is not None:
        return result
    raise exceptions.ApiError(response, data)
289413
def is_allowed(func):
    
    @wraps(func)
    def _is_allowed(user, *args, **kwargs):
        password = kwargs.pop('password', None)
        if user.check_password(password):
            return func(user, *args, **kwargs)
        else:
            raise NotAllowedError()

    # add password parameter to function signature
    sig = inspect.signature(func)
    parms = list(sig.parameters.values())
    parms.append(inspect.Parameter('password',
                                   inspect.Parameter.KEYWORD_ONLY,
                                   default=None))
    _is_allowed.__signature__ = sig.replace(parameters=parms)

    return _is_allowed