Validate a comma-separated list of scanners and extract it into a list of groups and IDs.
492349
def validate_scanner_list(ctx, param, value):
    
    if not value:
        return None

    valid_groups = ctx.obj.scanner_groups
    scanners = [x.strip() for x in value.split(',')]

    if 'all' in scanners:
        return ['all']

    scanner_ids = []
    for scanner in scanners:
        if scanner.isdigit():
            scanner_ids.append(scanner)
        elif scanner in valid_groups:
            scanner_ids += ctx.obj.scanner_group_map[scanner]
        else:
            raise click.BadParameter('Invalid scanner "{0}" provided. Must be a valid group or numeric ID.'
                                     .format(scanner))

    return scanner_ids
984027
def _perform_validation(self, path, value, results):
        
        name = path if path != None else "value"
        value = ObjectReader.get_value(value)

        super(ArraySchema, self)._perform_validation(path, value, results)

        if value == None:
            return

        if isinstance(value, list) or isinstance(value, set) or isinstance(value, tuple):
            index = 0
            for element in value:
                element_path = str(index) if path == None or len(path) == 0 else path + "." + str(index)
                self._perform_type_validation(element_path, self.value_type, element, results)
                index += 1
        else:
            results.append(
                ValidationResult(
                    path,
                    ValidationResultType.Error,
                    "VALUE_ISNOT_ARRAY",
                    name + " type must be List or Array",
                    "List",
                    type(value)
                )
            )
921640
def scan_arguments(*how)
      if how.count == 1
        pattern = how.first
      else
        left_delimiter = how[0] || self.left_delimiter
        right_delimiter = how[1] || self.right_delimiter

        return [] unless left_delimiter && right_delimiter

        pattern = Regexp.new(Regexp.escape(left_delimiter) + '(.*?)' + Regexp.escape(right_delimiter))
      end

      @arguments = @base.scan(pattern).flatten
    end
484669
function regexpToRegexp(regex, keys, options) {
  if (!Array.isArray(keys)) return regex.source;

  let groups = regex.source.match(/\((?!\?)/g);
  if (!groups) return regex.source;

  let i = 0;
  let group = () => ({
    name: i++,
    prefix: null,
    delimiter: null,
    optional: false,
    repeat: false,
    partial: false,
    pattern: null
  });

  groups.forEach(() => keys.push(group()));
  return regex.source;
}
587134
private String[][] parsePS(String[] psStrings) {
    String[][] result = new String[psStrings.length-1][NUM_FIELDS];
    for (int i = 1; i < psStrings.length; i++) {
      Matcher matcher = psPattern.matcher(psStrings[i]);
      if (matcher.find()) {
        for (int j = 0; j < NUM_FIELDS; j++) {
          result[i-1][j] = matcher.group(j+1);
        }
      }
    }
    return result;
  }
605043
def from_ids(cls, path:PathOrStr, vocab:Vocab, train_ids:Collection[Collection[int]], valid_ids:Collection[Collection[int]],
                 test_ids:Collection[Collection[int]]=None, train_lbls:Collection[Union[int,float]]=None,
                 valid_lbls:Collection[Union[int,float]]=None, classes:Collection[Any]=None,
                 processor:PreProcessor=None, **kwargs) -> DataBunch:
        ""
        src = ItemLists(path, TextList(train_ids, vocab, path=path, processor=[]),
                        TextList(valid_ids, vocab, path=path, processor=[]))
        src = src.label_for_lm() if cls==TextLMDataBunch else src.label_from_lists(train_lbls, valid_lbls, classes=classes, processor=[])
        if not is1d(train_lbls): src.train.y.one_hot,src.valid.y.one_hot = True,True
        if test_ids is not None: src.add_test(TextList(test_ids, vocab, path=path), label=train_lbls[0])
        src.valid.x.processor = ifnone(processor, [TokenizeProcessor(), NumericalizeProcessor(vocab=vocab)])
        return src.databunch(**kwargs)
1291673
def validate_abi(abi):
    
    if not is_list_like(abi):
        raise ValueError("'abi' is not a list")

    if not all(is_dict(e) for e in abi):
        raise ValueError("'abi' is not a list of dictionaries")

    functions = filter_by_type('function', abi)
    selectors = groupby(
        compose(encode_hex, function_abi_to_4byte_selector),
        functions
    )
    duplicates = valfilter(lambda funcs: len(funcs) > 1, selectors)
    if duplicates:
        raise ValueError(
            'Abi contains functions with colliding selectors. '
            'Functions {0}'.format(_prepare_selector_collision_msg(duplicates))
        )
326147
private String[] scan( FileSet fileSet )
    {
        File basedir = new File( fileSet.getDirectory() );
        if ( !basedir.exists() || !basedir.isDirectory() )
        {
            return null;
        }

        DirectoryScanner scanner = new DirectoryScanner();

        List<String> includes = fileSet.getIncludes();
        List<String> excludes = fileSet.getExcludes();

        if ( includes != null && includes.size() > 0 )
        {
            scanner.setIncludes( includes.toArray( new String[0] ) );
        }

        if ( excludes != null && excludes.size() > 0 )
        {
            scanner.setExcludes( excludes.toArray( new String[0] ) );
        }

        scanner.setBasedir( basedir );

        scanner.scan();
        return scanner.getIncludedFiles();
    }
422762
function (scanner, matcher) {
  var start = scanner.pos;
  var result = matcher(scanner);
  scanner.pos = start;
  return result;
}
195933
private void validateKeyTypes(int[] keyFieldIndices) {
		final TypeInformation<?>[] types = getFieldTypes();
		for (int keyFieldIndex : keyFieldIndices) {
			final TypeInformation<?> type = types[keyFieldIndex];
			if (!TypeCheckUtils.isSimpleStringRepresentation(type)) {
				throw new ValidationException(
					"Only simple types that can be safely converted into a string representation " +
						"can be used as keys. But was: " + type);
			}
		}
	}
190923
private static int[] parseIntList(
            String commaSeparatedString, int absmin, int absmax, IcalSchema schema)
            throws ParseException {

        String[] parts = COMMA.split(commaSeparatedString);
        int[] out = new int[parts.length];
        for (int i = parts.length; --i >= 0; ) {
            try {
                int n = Integer.parseInt(parts[i]);
                int absn = Math.abs(n);
                if (!(absmin <= absn && absmax >= absn)) {
                    schema.badPart(commaSeparatedString, null);
                }
                out[i] = n;
            } catch (NumberFormatException ex) {
                schema.badPart(commaSeparatedString, ex.getMessage());
            }
        }
        return out;
    }
724660
function asRegExps(array) {
    var array = asArray(array), len = array.length;
    for (var i = 0; i < len; i++) {
        if (!(array[i] instanceof RegExp)) {
            array[i] = new RegExp(array[i]);
        }
    }
    return array;
}
968881
def _common_scan(self, values_function, cursor='0', match=None, count=10, key=None):
        
        if count is None:
            count = 10
        cursor = int(cursor)
        count = int(count)
        if not count:
            raise ValueError('if specified, count must be > 0: %s' % count)

        values = values_function()
        if cursor + count >= len(values):
            # we reached the end, back to zero
            result_cursor = 0
        else:
            result_cursor = cursor + count

        values = values[cursor:cursor+count]

        if match is not None:
            regex = re.compile(b'^' + re.escape(self._encode(match)).replace(b'\\*', b'.*') + b'$')
            if not key:
                key = lambda v: v
            values = [v for v in values if regex.match(key(v))]

        return [result_cursor, values]
1134754
private List<Integer> extractRgroups(String data){
	  Pattern pattern = Pattern.compile("R[1-9]\\d*");
	  Matcher matcher = pattern.matcher(data);
	  List<Integer> listValues = new ArrayList<Integer>();
	  
	  while(matcher.find()){
		listValues.add(Integer.parseInt(matcher.group().split("R")[1]));  
	  }
	  return listValues;
  }
282511
def validate_obj(keys, obj):
    """"""
    msg = ''
    for k in keys:
        if isinstance(k, str):
            if k not in obj or (not isinstance(obj[k], list) and not obj[k]):
                if msg:
                    msg = "%s," % msg

                msg = "%s%s" % (msg, k)
        elif isinstance(k, list):
            found = False
            for k_a in k:
                if k_a in obj:
                    found = True

            if not found:
                if msg:
                    msg = "%s," % msg

                msg = "%s(%s" % (msg, ','.join(k))

    if msg:
        msg = "%s missing" % msg

    return msg
746038
def get_unique_groups(input_list):
    """"""
    out_list = []
    for item in input_list:
        if item not in out_list:
            out_list.append(item)
    return out_list
232404
def iddtxt2groups(txt):
    """"""
    try:
        txt = txt.decode('ISO-8859-2')
    except AttributeError as e:
        pass # for python 3
    txt = nocomment(txt, '!')
    txt = txt.replace("\\group", "!-group") # retains group in next line
    txt = nocomment(txt, '\\') # remove all other idd info
    lines = txt.splitlines()
    lines = [line.strip() for line in lines] # cleanup
    lines = [line for line in lines if line != ''] # cleanup
    txt = '\n'.join(lines)
    gsplits = txt.split('!') # split into groups, since we have !-group
    gsplits = [gsplit.splitlines() for gsplit in gsplits] # split group

    gsplits[0].insert(0, None)
        # Put None for the first group that does nothave a group name
    gdict = {}
    for gsplit in gsplits:
        gdict.update({gsplit[0]:gsplit[1:]})
        # makes dict {groupname:[k1, k2], groupname2:[k3, k4]}

    gdict = {k:'\n'.join(v) for k, v in gdict.items()}# joins lines back
    gdict = {k:v.split(';') for k, v in gdict.items()} # splits into idfobjects
    gdict = {k:[i.strip() for i in v] for k, v in gdict.items()} # cleanup
    gdict = {k:[i.splitlines() for i in v] for k, v in gdict.items()}
        # splits idfobjects into lines
    gdict = {k:[i for i in v if len(i) > 0] for k, v in gdict.items()}
        # cleanup - removes blank lines
    gdict = {k:[i[0] for i in v] for k, v in gdict.items()} # use first line
    gdict = {k:[i.split(',')[0] for i in v] for k, v in gdict.items()}
        # remove ','
    nvalue = gdict.pop(None) # remove group with no name
    gdict = {k[len('-group '):]:v for k, v in gdict.items()} # get group name
    gdict.update({None:nvalue}) # put back group with no name
    return gdict