Check if arguments are of protocol type.
768447
def enum_check(*args, func=None):
    """"""
    func = func or inspect.stack()[2][3]
    for var in args:
        if not isinstance(var, (enum.EnumMeta, aenum.EnumMeta)):
            name = type(var).__name__
            raise EnumError(
                f'Function {func} expected enumeration, {name} got instead.')
688489
def CheckInputArgs(*interfaces):
    
    l = len(interfaces)
    def wrapper(func):
        def check_args(self, *args, **kw):
            for i in range(len(args)):
                if (l > i and interfaces[i].providedBy(args[i])) or interfaces[-1].providedBy(args[i]):
                    continue
                if l > i: raise TypeError, 'arg %s does not implement %s' %(args[i], interfaces[i])
                raise TypeError, 'arg %s does not implement %s' %(args[i], interfaces[-1])
            func(self, *args, **kw)
        return check_args
    return wrapper
734466
function validArguments() {
    var conditions = {
      'port and host': function () {
        return port && host;
      },
      'options.target or options.router': function () {
        return options && (options.router ||
          (options.target && options.target.host && options.target.port));
      },
      'or proxy handlers': function () {
        return handlers && handlers.length;
      }
    }

    var missing = Object.keys(conditions).filter(function (name) {
      return !conditions[name]();
    });

    if (missing.length === 3) {
      message = 'Cannot proxy without ' + missing.join(', ');
      return false;
    }

    return true;
  }
1281957
def arg_check(args, types = nil, server = nil)
      return args unless types

      args.each_with_index.map do |arg, i|
        next arg if types[i].nil? || types[i] == String

        if types[i] == Integer
          begin
            Integer(arg)
          rescue ArgumentError
            nil
          end
        elsif types[i] == Float
          begin
            Float(arg)
          rescue ArgumentError
            nil
          end
        elsif types[i] == Time
          begin
            Time.parse arg
          rescue ArgumentError
            nil
          end
        elsif types[i] == TrueClass || types[i] == FalseClass
          if arg.casecmp('true').zero? || arg.downcase.start_with?('y')
            true
          elsif arg.casecmp('false').zero? || arg.downcase.start_with?('n')
            false
          end
        elsif types[i] == Symbol
          arg.to_sym
        elsif types[i] == Encoding
          begin
            Encoding.find arg
          rescue ArgumentError
            nil
          end
        elsif types[i] == Regexp
          begin
            Regexp.new arg
          rescue ArgumentError
            nil
          end
        elsif types[i] == Rational
          begin
            Rational(arg)
          rescue ArgumentError
            nil
          end
        elsif types[i] == Range
          begin
            if arg.include? '...'
              Range.new(*arg.split('...').map(&:to_i), true)
            elsif arg.include? '..'
              Range.new(*arg.split('..').map(&:to_i))
            end
          rescue ArgumentError
            nil
          end
        elsif types[i] == NilClass
          nil
        elsif [Discordrb::User, Discordrb::Role, Discordrb::Emoji].include? types[i]
          result = parse_mention arg, server
          result if result.instance_of? types[i]
        elsif types[i] == Discordrb::Invite
          resolve_invite_code arg
        elsif types[i].respond_to?(:from_argument)
          begin
            types[i].from_argument arg
          rescue StandardError
            nil
          end
        else
          raise ArgumentError, "#{types[i]} doesn't implement from_argument"
        end
      end
    end
799179
def identify_protocol(method, value):
    # type: (str, Union[str, RequestType]) -> str
    
    for protocol_name in PROTOCOLS:
        protocol = importlib.import_module(f"federation.protocols.{protocol_name}.protocol")
        if getattr(protocol, f"identify_{method}")(value):
            return protocol
    else:
        raise NoSuitableProtocolFoundError()
690072
def _checkType(self, obj, identifier):
        """"""
        if not isinstance(obj, basestring):
            raise TypeError("expected %s '%s' to be a string (was '%s')" %
                            (identifier, obj, type(obj).__name__))
742060
def protocol_str(protocol):
    """"""
    if protocol == const.PROTOCOL_MRP:
        return 'MRP'
    if protocol == const.PROTOCOL_DMAP:
        return 'DMAP'
    if protocol == const.PROTOCOL_AIRPLAY:
        return 'AirPlay'
    return 'Unknown'
640295
def validate(self, protocol_version, values=None):
        """"""
        if values is None:
            values = self.values
        return self.get_schema(protocol_version)(values)
907828
private NetProtocol checkProtocol(String protocol)
    {
        //  First check out whether the protcol is something we are aware of.
        NetProtocol proto = NetProtocol.getProtocol(protocol);
        if (proto == null || !proto.valid) {
            errno.set(ZError.EPROTONOSUPPORT);
            return proto;
        }

        //  Check whether socket type and transport protocol match.
        //  Specifically, multicast protocols can't be combined with
        //  bi-directional messaging patterns (socket types).
        if (!proto.compatible(options.type)) {
            errno.set(ZError.ENOCOMPATPROTO);
            return null;
        }
        //  Protocol is available.
        return proto;
    }
767974
def is_str(arg):
    '''
     
    '''
    return (isinstance(arg, six.string_types) or
            is_npscalar(arg, 'string') or
            is_npvalue(arg, 'string'))
260817
def check_invocation(node, type)
      args = sort_args_by_position(node.args,
                                   node.splat,
                                   node.keywords.values,
                                   node.kwarg_splat)

      check_commas_after_args(args, "#{type} arguments")
    end
1148929
def _check(self, args):
        """"""
        if sum(bool(args[arg]) for arg in self._mapping) > 1:
            raise DocoptExit(_('These options are mutually exclusive: {0}',
                               ', '.join(self._mapping)))
126109
function verifyArguments(args) {
	const isInvalid = args.some((arg) => typeof arg !== 'string');
	if (isInvalid) {
		const argsString = args.map((arg) => util.format('%j', arg)).join(', ');
		const msg = util.format('Transaction arguments must be strings: %s', argsString);
		logger.error('verifyArguments:', msg);
		throw new Error(msg);
	}
}
1256364
boolean isNegotiable(ProtocolVersion protocolVersion) {
        if (activeProtocols == null) {
            activeProtocols = getActiveProtocols();
        }

        return activeProtocols.contains(protocolVersion);
    }
1021952
function(args, types) {
		this._validating = true;
		var is = this._match(args, types);
		this._validating = false;
		return is;
	}
959781
function checkArrayTypes() {
  var t, i;
  for (i = 0; i < arguments.length; i++) {
     if ((t = Object.prototype.toString.call(arguments[i])) !== '[object Uint8Array]')
       throw new TypeError('unexpected type ' + t + ', use Uint8Array');
  }
}
209163
def _validate_argument(self, arg):
        """"""
        if arg is None:
            return arg

        if isinstance(arg, type):
            return InstanceOf(arg)
        if not isinstance(arg, BaseMatcher):
            raise TypeError(
                "argument of %s can be a type or a matcher (got %r)" % (
                    self.__class__.__name__, type(arg)))

        return arg