parse a string into a list of a uniform type
764092
def parse_utuple(s,urx,length=2):
    ''''''
    if type(urx) != str:
        urx=urx.pattern;
    if length is not None and length < 1:
        raise ValueError("invalid length: {}".format(length));
    if length == 1:
        rx = r"^ *\( *{urx} *,? *\) *$".format(urx=urx);
    elif length is None:
        rx = r"^ *\( *(?:{urx} *, *)*{urx} *,? *\) *$".format(urx=urx);
    else:
        rx = r"^ *\( *(?:{urx} *, *){{{rep1}}}{urx} *,? *\) *$".format(
            rep1=length-1,
            urx=urx);
    return re.match(rx,s);
653842
def to_list(var):
    """"""
    if var is None:
        return []
    if isinstance(var, str):
        var = var.split('\n')
    elif not isinstance(var, list):
        try:
            var = list(var)
        except TypeError:
            raise ValueError("{} cannot be converted to the list.".format(var))
    return var
1372963
def eval_str_to_list(input_str: str) -> List[str]:
    """"""
    inner_cast = ast.literal_eval(input_str)  # type: List[str]
    if isinstance(inner_cast, list):
        return inner_cast
    else:
        raise ValueError
602431
static Type parse(String str) {
        try {
            return doParse(str);
        } catch (RuntimeException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
1268135
private FormatString[] parse(String s) {
        ArrayList<FormatString> al = new ArrayList<>();
        for (int i = 0, len = s.length(); i < len; ) {
            int nextPercent = s.indexOf('%', i);
            if (s.charAt(i) != '%') {
                // This is plain-text part, find the maximal plain-text
                // sequence and store it.
                int plainTextStart = i;
                int plainTextEnd = (nextPercent == -1) ? len: nextPercent;
                al.add(new FixedString(s.substring(plainTextStart,
                                                   plainTextEnd)));
                i = plainTextEnd;
            } else {
                // We have a format specifier
                FormatSpecifierParser fsp = new FormatSpecifierParser(s, i + 1);
                al.add(fsp.getFormatSpecifier());
                i = fsp.getEndIdx();
            }
        }
        return al.toArray(new FormatString[al.size()]);
    }
876605
def toList(variable, types=(basestring, int, float, )):
    
    if isinstance(variable, types):
        return [variable]
    else:
        return variable
1028450
def flat_list(input_list):
    

    """
    x = input_list
    if isinstance(x, list):
        return [a for i in x for a in flat_list(i)]
    else:
        return [x]
590079
def _parse_value(value):
    ''''''
    if isinstance(value, bool):
        return 'true' if value else 'false'
    elif isinstance(value, six.string_types):
        # parse compacted notation to dict
        listparser = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''')

        value = value.strip()
        if value.startswith('[') and value.endswith(']'):
            return listparser.split(value[1:-1])[1::2]
        elif value.startswith('(') and value.endswith(')'):
            rval = {}
            for pair in listparser.split(value[1:-1])[1::2]:
                pair = pair.split('=')
                if '"' in pair[1]:
                    pair[1] = pair[1].replace('"', '')
                if pair[1].isdigit():
                    rval[pair[0]] = int(pair[1])
                elif pair[1] == 'true':
                    rval[pair[0]] = True
                elif pair[1] == 'false':
                    rval[pair[0]] = False
                else:
                    rval[pair[0]] = pair[1]
            return rval
        else:
            if '"' in value:
                value = value.replace('"', '')
            if value.isdigit():
                return int(value)
            elif value == 'true':
                return True
            elif value == 'false':
                return False
            else:
                return value
    else:
        return value
1203097
def _parse_list(s):
    """"""
    # Range: 'x-y'
    if '-' in s:
        m, M = map(_parse_arg, s.split('-'))
        return list(range(m, M + 1))
    # List of ids: 'x,y,z'
    elif ',' in s:
        return list(map(_parse_arg, s.split(',')))
    else:
        return _parse_arg(s)
807035
def __convert_string_list(node):
    """"""
    converted = __convert_node(node)

    # Determine flags for the string list
    flags = vsflags(VSFlags.UserValue)

    # Check for a separator to determine if it is semicolon appendable
    # If not present assume the value should be ;
    separator = __get_attribute(node, 'Separator', default_value=';')

    if separator == ';':
        flags = vsflags(flags, VSFlags.SemicolonAppendable)

    converted['flags'] = flags

    return __check_for_flag(converted)
853694
def _parse(self, pattern):
        """"""
        # Comma separated ranges
        if pattern.find(',') < 0:
            subranges = [pattern]
        else:
            subranges = pattern.split(',')

        for subrange in subranges:
            if subrange.find('/') < 0:
                step = 1
                baserange = subrange
            else:
                baserange, step = subrange.split('/', 1)

            try:
                step = int(step)
            except ValueError:
                raise RangeSetParseError(subrange,
                        "cannot convert string to integer")

            if baserange.find('-') < 0:
                if step != 1:
                    raise RangeSetParseError(subrange,
                            "invalid step usage")
                begin = end = baserange
            else:
                begin, end = baserange.split('-', 1)

            # compute padding and return node range info tuple
            try:
                pad = 0
                if int(begin) != 0:
                    begins = begin.lstrip("0")
                    if len(begin) - len(begins) > 0:
                        pad = len(begin)
                    start = int(begins)
                else:
                    if len(begin) > 1:
                        pad = len(begin)
                    start = 0
                if int(end) != 0:
                    ends = end.lstrip("0")
                else:
                    ends = end
                stop = int(ends)
            except ValueError:
                raise RangeSetParseError(subrange,
                        "cannot convert string to integer")

            # check preconditions
            if stop > 1e100 or start > stop or step < 1:
                raise RangeSetParseError(subrange,
                                         "invalid values in range")

            self.add_range(start, stop + 1, step, pad)
646740
def parse(self, string, parent):
        """"""
        result = {}
        for member in self.RE_MEMBERS.finditer(string):
            mems = self._process_member(member, parent, string)
            #The regex match could contain multiple members that were defined
            #on the same line in the code file.
            for onemem in mems:
                result[onemem.name.lower()] = onemem
                
        return result
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;
  }
437227
def parse_pattern_list(liststr):
    """"""
    _re_patt = re.compile("^(.*)=(.*)")
    patterns = []
    for ss in liststr.split(';'):
        match = _re_patt.match(ss)
        if match:
            desc = match.group(1)
            patt = match.group(2).split(',')
            patterns.append((desc, patt))
    return patterns
360429
def kw_str_parse(a_string):
    """"""
    try:
        return dict((k, eval(v.rstrip(',')))
                    for k, v in kw_list_re.findall(a_string))
    except (AttributeError, TypeError):
        if isinstance(a_string, collections.Mapping):
            return a_string
        return {}
436205
function parseFilter(filterString) {

    var ret = Color$1.convertMatches(filterString);
    var matches = ret.str.match(filter_regexp);

    if (!matches[0]) {
        return [];
    }

    var arr = matches[0].split('(');

    var filterName = arr.shift();
    var filterParams = [];

    if (arr.length) {
        filterParams = arr.shift().split(')')[0].split(',').map(function (f) {
            return Color$1.reverseMatches(f, ret.matches);
        });
    }

    var result = [filterName].concat(toConsumableArray(filterParams)).map(Color$1.trim);

    return result;
}
1080193
private static List<String> split(String str) {
        List<String> result = new ArrayList<String>();
        int genericCount = 0;
        int startPos = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == ',' && genericCount == 0) {
                result.add(str.substring(startPos, i).trim());
                startPos = i + 1;
            } else if (str.charAt(i) == '<') {
                genericCount++;
            } else if (str.charAt(i) == '>') {
                genericCount--;
            }
        }
        result.add(str.substring(startPos).trim());
        return result;
    }