Argument check helper
489535
public static AstNumList check(long dstX, AstRoot ast) {
    // Sanity check vs dst.  To simplify logic, jam the 1 col/row case in as a AstNumList
    AstNumList dim;
    if (ast instanceof AstNumList) dim = (AstNumList) ast;
    else if (ast instanceof AstNum) dim = new AstNumList(((AstNum) ast).getNum());
    else throw new IllegalArgumentException("Requires a number-list, but found a " + ast.getClass());
    if (dim.isEmpty()) return dim; // Allow empty
    for (int col : dim.expand4())
      if (!(0 <= col && col < dstX))
        throw new IllegalArgumentException("Selection must be an integer from 0 to " + dstX);
    return dim;
  }
502789
def _parse_arguments(arguments=None):
    """"""
    dir_hash = hashlib.sha1(os.getcwd().encode("utf-8")).hexdigest()

    parser = argparse.ArgumentParser(description="""Lint for Polysquare style guide""")
    parser.add_argument("--checks",
                        nargs=0,
                        action=ShowAvailableChecksAction,
                        help="""list available checks""")
    parser.add_argument("files",
                        nargs="*",
                        metavar=("FILE"),
                        help="""read FILE""",
                        type=str)
    parser.add_argument("--whitelist",
                        nargs="*",
                        help="""list of checks that should only be run""",
                        default=None)
    parser.add_argument("--blacklist",
                        nargs="*",
                        help="""list of checks that should never be run""",
                        default=None)
    parser.add_argument("--fix-what-you-can",
                        action="store_const",
                        help="""fix errors automatically""",
                        const=True)
    parser.add_argument("--spellcheck-cache",
                        help="""path to spell-checking cache file""",
                        default=None)
    parser.add_argument("--log-technical-terms-to",
                        help="""path to file to log technical terms to""",
                        default=None)
    parser.add_argument("--stamp-file-path",
                        help="""path to directory to store cached results""",
                        default=os.path.join(tempfile.gettempdir(),
                                             "jobstamps",
                                             "spellcheck_linter",
                                             dir_hash))
    parser.add_argument("--block-regexps",
                        help="""Regular expressions to exclude from all checks.""",
                        nargs="*",
                        default=None)

    return parser.parse_args(arguments)
975325
private void checkOneArg(List<String> args, int index) throws OptionException {
        if ((index + 1) >= args.size() || args.get(index + 1).startsWith("-d")) {
            String text = messager.getText("main.requires_argument", args.get(index));
            throw new OptionException(CMDERR, this::usage, text);
        }
    }
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
161634
def argument(self) -> bool:
        
        next = self.peek()
        if next == "'":
            quoted = True
            self.sq_argument()
        elif next == '"':
            quoted = True
            self.dq_argument()
        elif self._arg == "":
            quoted = False
            self.unq_argument()
        else:
            raise UnexpectedInput(self, "single or double quote")
        self.opt_separator()
        next = self.peek()
        if next == ";":
            return False
        if next == "{":
            return True
        elif quoted and next == "+":
            self.offset += 1
            self.opt_separator()
            return self.argument()
        else:
            raise UnexpectedInput(self, "';', '{'" +
                                  (" or '+'" if quoted else ""))
661914
function check(args, names) {
                var msg         = '',
                    name        = '',
                    template    = '{{ name }} coud not be empty!',
                    
                    indexOf     = Array.prototype.indexOf,
                    
                    lenNames    = names.length,
                    lenArgs     = args.length,
                    lessArgs    = lenArgs < lenNames,
                    emptyIndex  = indexOf.call(args),
                    isEmpty     = ~emptyIndex;
                
                if (lessArgs || isEmpty) {
                    if (lessArgs)
                        name        = names[lenNames - 1];
                    else
                        name        = names[emptyIndex];
                    
                    msg         = Util.render(template, {
                        name: name
                    });
                    
                    throw(Error(msg));
                }
                
                return check;
            }
841550
def validate_args(args):
    
    if not os.path.isdir(args.directory):
        print "Directory {} does not exist".format(args.directory)
        sys.exit(5)
    return args
1046280
def validate_arguments(args):
    """"""

    #check arguments
    print
    print "Checking input...",

    semantic_tests = ["animals", "custom"]
    phonemic_tests = ["a", "p", "s", "f"]
    if args.similarity_file:
        print
        print "Custom similarity file was specified..."
        args.semantic = "custom"

    if args.threshold:
        try:
            args.threshold = float(args.threshold)
        except ValueError:
            raise VFClustException('Custom threshold (--threshold argument) must be a number.')


    if not (args.source_file_path.lower().endswith('csv') or args.source_file_path.lower().endswith('textgrid')):
        raise VFClustException('The input must be either a .TextGrid or .csv file!\nYou provided ' + args.source_file_path.lower())
    if not os.path.isfile(args.source_file_path):
        raise VFClustException('The input file path you provided does not exist on your system!')

    #if no output path provided, write to source file path
    if args.output_path == None:
        args.output_path = args.source_path
    #if output_path is False, don't output anything
    elif args.output_path == False:
        pass
    else:
        #verify/make folders for output
        if len(args.output_path) == 0:
            args.output_path = os.path.abspath(os.path.dirname(args.source_file_path))
        try:
            if not os.path.isdir(args.output_path):
                os.mkdir(args.output_path)
        except:
            print "Error creating folder for program output. " \
                  "Make sure you have write permissions to the folder you provided. " \
                  "You can change the folder with the -o option." \
                  "The output directory will be the same as the input directory."


    #make phonemic and semantic args lower case
    if (args.semantic): args.semantic = args.semantic.lower()
    if (args.phonemic): args.phonemic = args.phonemic.lower()

    #must choose either semantic or phonemic
    if not (args.semantic or args.phonemic):
        print "DEBUG", args.semantic, args.similarity_file
        raise VFClustException(
            '''You must specify at least one phonemic or semantic test to run using -p or -s, followed by the test type.
            Alternatively, provide a custom similarity file using the --similarity-file and --threshold options.''')

    #make sure semantic arguments are legit
    if args.semantic and args.semantic not in semantic_tests:
        raise VFClustException("Currently only " + ",".join(semantic_tests) + " are supported for semantic testing. " \
                                                       "You provided " + args.semantic)

    if args.phonemic and args.phonemic not in phonemic_tests:
        raise VFClustException("Currently only " + ",".join(phonemic_tests) + " are supported for phonemic testing.  " \
                                                       "You provided " + args.phonemic)


    if (args.phonemic and args.semantic):
        raise VFClustException("You must choose EITHER semantic OR phonemic clustering.")

    #make paths absolute
    args.source_file_path = os.path.abspath(args.source_file_path)
    if args.output_path:
        args.output_path = os.path.abspath(args.output_path)

    #using custom similarity file
    if args.similarity_file: #if it's not None
        if not os.path.isfile(args.similarity_file):
            raise VFClustException('The custom similarity file path you provided does not exist on your system!')
        if not args.threshold:
            raise VFClustException('You must specify a clustering threshold when using a custom similarity file. Use --threshold X, where X is the threshold number.')
        try:
            args.threshold = float(args.threshold)
        except:
            raise VFClustException('Error reading the custom threshold you provided. It must be a number, e.g. --threshold 6.7 or --threshold 10')
        args.similarity_file = os.path.abspath(args.similarity_file)

    print "OK!"
    print
    print "Parsed arguments:"
    print_table([(k, str(vars(args)[k])) for k in vars(args)])

    return args
1356865
def callable_check(func, arg_count=1, arg_value=None, allow_none=False):
        """"""
        if func is None:
            if not allow_none:
                raise ValueError('callable cannot be None')
        elif not arg_checker(func, *[arg_value for _ in range(arg_count)]):
            raise ValueError('callable %s invalid (for %d arguments)' % (func, arg_count))
220438
function collectArguments(args) {
  for (var i = 0; i < args.length; i += 2) {
    if (args[i].lastIndexOf('--', 0) !== 0) {
      --i;
      continue;
    }

    flags[args[i]] = args[i + 1];
  }
}
1365358
def _parse_argument(cls, token):
        
        description = ""
        validator = None

        if " : " in token:
            token, description = tuple(token.split(" : ", 2))

            token = token.strip()

            description = description.strip()

        # Checking validator:
        matches = re.match(r"(.*)\((.*?)\)", token)
        if matches:
            token = matches.group(1).strip()
            validator = matches.group(2).strip()

        if token.endswith("?*"):
            return _argument(
                token.rstrip("?*"),
                Argument.MULTI_VALUED | Argument.OPTIONAL,
                description,
                None,
            )
        elif token.endswith("*"):
            return _argument(
                token.rstrip("*"),
                Argument.MULTI_VALUED | Argument.REQUIRED,
                description,
                None,
            )
        elif token.endswith("?"):
            return _argument(token.rstrip("?"), Argument.OPTIONAL, description, None)

        matches = re.match(r"(.+)=(.+)", token)
        if matches:
            return _argument(
                matches.group(1), Argument.OPTIONAL, description, matches.group(2)
            )

        return _argument(token, Argument.REQUIRED, description, None)
765939
function checkArgument(i) {
  let l;

  if (l = checkBrackets(i)) tokens[i].argument_child = 1;
  else if (l = checkParentheses(i)) tokens[i].argument_child = 2;
  else if (l = checkSingleValueDeclaration(i)) tokens[i].argument_child = 3;
  else if (l = checkFunctionsList(i)) tokens[i].argument_child = 4;
  else if (l = checkFunction(i)) tokens[i].argument_child = 5;
  else if (l = checkVariablesList(i)) tokens[i].argument_child = 6;
  else if (l = checkVariable(i)) tokens[i].argument_child = 7;
  else if (l = checkSC(i)) tokens[i].argument_child = 8;
  else if (l = checkDelim(i)) tokens[i].argument_child = 9;
  else if (l = checkDeclDelim(i)) tokens[i].argument_child = 10;
  else if (l = checkString(i)) tokens[i].argument_child = 11;
  else if (l = checkPercentage(i)) tokens[i].argument_child = 12;
  else if (l = checkDimension(i)) tokens[i].argument_child = 13;
  else if (l = checkNumber(i)) tokens[i].argument_child = 14;
  else if (l = checkUri(i)) tokens[i].argument_child = 15;
  else if (l = checkInterpolation(i)) tokens[i].argument_child = 16;
  else if (l = checkIdent(i)) tokens[i].argument_child = 17;
  else if (l = checkVhash(i)) tokens[i].argument_child = 18;
  else if (l = checkCustomProperty(i)) tokens[i].argument_child = 19;
  else if (l = checkOperator(i)) tokens[i].argument_child = 20;
  else if (l = checkUnary(i)) tokens[i].argument_child = 21;
  else if (l = checkParentSelector(i)) tokens[i].argument_child = 22;
  else if (l = checkImportant(i)) tokens[i].argument_child = 23;
  else if (l = checkGlobal(i)) tokens[i].argument_child = 24;
  else if (l = checkDefault(i)) tokens[i].argument_child = 25;
  else if (l = checkOptional(i)) tokens[i].argument_child = 26;

  return l;
}
856388
public static void checkArgument(boolean b, String msg, Object arg1) {
        if (!b) {
            throwEx(msg, arg1);
        }
    }
203777
function checkForUnknownArguments (yargs, argv) {
    var aliasLookup = {};
    var descriptions = yargs.getUsageInstance().getDescriptions();
    var demanded = yargs.getDemanded();
    var unknown = [];

    Object.keys(yargs.parsed.aliases || {}).forEach(function (key) {
        yargs.parsed.aliases[key].forEach(function (alias) {
            aliasLookup[alias] = key;
        });
    });

    Object.keys(argv).forEach(function (key) {
        if (key !== '$0' && key !== '_' && key !== 'params' &&
            !descriptions.hasOwnProperty(key) &&
            !demanded.hasOwnProperty(key) &&
            !aliasLookup.hasOwnProperty('no-' + key) &&
            !aliasLookup.hasOwnProperty(key)) {
                unknown.push(key);
        }
    });

    if (unknown.length === 1) {
        throw Cli.usageError('Unknown argument: ' + unknown[0]);
    } else if (unknown.length > 1) {
        throw Cli.usageError('Unknown arguments: ' + unknown.join(', '));
    }
}
1362923
function castArgument(arg) {
		if (isNumber(arg)) {
			return parseFloat(arg);
		}

		if (helpers.isFraction(arg)) {
			arg = arg.split('/');

			return arg[0] / arg[1];
		}

		if (arg === 'false' || arg === 'true') {
			return arg === 'true';
		}

		return arg.length ? arg : undefined;
	}
283568
def check_args!
      ::Hash[@args.zip(::ARGV)].each do |arg_name,arg_value|
        if @arg_options[arg_name].include? :required
          if arg_value.nil?
            message = "'#{arg_name.to_s}' is required"
            message = "at least one " + message if @arg_options[arg_name].include? :many
            raise ::OptionParser::ParseError,message
          end
        end
      end
    end
1010064
def validate_args(self):
        """"""
        def validate_name():
            allowed_re = '^[a-z](([a-z0-9_-]+)?([a-z0-9])?)?'
            assert isinstance(self.params['name'], basestring), (
                'Name must be a string, not %s' % repr(self.params['name']))
            assert re.match(allowed_re, self.params['name']), (
                'Invalid rule name: %s. Must match %s.' % (
                    repr(self.params['name']), repr(allowed_re)))
        validate_name()

        def validate_deps():
            if 'deps' in self.params:
                assert type(self.params['deps']) in (type(None), list), (
                    'Deps must be a list, not %s' % repr(self.params['deps']))
        validate_deps()