Parse the value from the given text, using the specified format.
330764
public void setAsText(String text) throws IllegalArgumentException {
        if (this.allowEmpty && !StringUtils.hasText(text)) {
            // Treat empty String as null value.
            setValue(null);
        } else {
            setValue(new LocalDate(this.formatter.parseDateTime(text)));
        }
    }
689401
def parse(text, base=None, chop=False):
    '''
    
    '''
    #TODO: use base to facilitate relative time offsets
    text = text.strip().lower()
    text = (''.join([c for c in text if c.isdigit()]))

    if chop:
        text = text[:17]

    # TODO: support relative time offsets here...

    tlen = len(text)
    if tlen == 4:
        dt = datetime.datetime.strptime(text, '%Y')

    elif tlen == 6:
        dt = datetime.datetime.strptime(text, '%Y%m')

    elif tlen == 8:
        dt = datetime.datetime.strptime(text, '%Y%m%d')

    elif tlen == 10:
        dt = datetime.datetime.strptime(text, '%Y%m%d%H')

    elif tlen == 12:
        dt = datetime.datetime.strptime(text, '%Y%m%d%H%M')

    elif tlen == 14:
        dt = datetime.datetime.strptime(text, '%Y%m%d%H%M%S')

    elif tlen in (15, 16, 17):
        dt = datetime.datetime.strptime(text, '%Y%m%d%H%M%S%f')

    else:
        raise s_exc.BadTypeValu(valu=text, name='time',
                                mesg='Unknown time format')

    epoch = datetime.datetime(1970, 1, 1)
    return int((dt - epoch).total_seconds() * 1000)
141134
def parse_value(self, frmtcode, buff, start, end):
        '''
            
        '''
        
        frmttype = self.util._formatmap[frmtcode]
        if(frmtcode == FormatType.FLOAT_32.value.code):  # @UndefinedVariable
            return self.parse_float32(buff, start, end)
        elif(frmtcode == FormatType.FLOAT_64.value.code):  # @UndefinedVariable
            return self.parse_float64(buff, start, end)
        if frmttype.value.idx <= FormatType.FIXSTR.value.idx:  # @UndefinedVariable  
            return self.parse_str(buff, start, end)
        elif frmttype.value.idx <= FormatType.INT_64.value.idx:  # @UndefinedVariable
            return self.parse_int(buff, start, end)
        elif frmttype.value.idx <= FormatType.UINT_64.value.idx:  # @UndefinedVariable
            return self.parse_uint(buff, start, end)
916058
def parse_format_index(self, text):
        """"""

        base = 10
        prefix = text[1:3] if text[0] == "-" else text[:2]
        if prefix[0:1] == "0":
            char = prefix[-1]
            if char == "b":
                base = 2
            elif char == "o":
                base = 8
            elif char == "x":
                base = 16
        try:
            text = int(text, base)
        except Exception:
            pass
        return text
426687
def parsedate(data):
    """"""
    t = parsedate_tz(data)
    if isinstance(t, tuple):
        return t[:9]
    else:
        return t
900228
def parse(text, verbose=False):
    """"""
    log_format = ('%(asctime)s --- %(message)s')
    logging.basicConfig(format=log_format)
    root = logging.getLogger()

    if verbose:
        level = root.level
        root.setLevel(logging.DEBUG)
        logging.debug(u'Verbose mode')

    if isinstance(text, str):
        text = text.decode('utf-8')
        logging.debug(u'Converted string to unicode (assume utf-8 encoding)')

    orig_text = text
    logging.debug(u'Original text: "%s"', orig_text)

    text = clean_text(text)
    values = extract_spellout_values(text)
    text, shifts = substitute_values(text, values)

    quantities = []
    for item in r.REG_DIM.finditer(text):

        groups = dict([i for i in item.groupdict().items() if i[1] and
                       i[1].strip()])
        logging.debug(u'Quantity found: %s', groups)

        try:
            uncert, values = get_values(item)
        except ValueError as err:
            logging.debug(u'Could not parse quantity: %s', err)

        unit = get_unit(item, text)
        surface, span = get_surface(shifts, orig_text, item, text)
        objs = build_quantity(orig_text, text, item, values, unit, surface,
                              span, uncert)
        if objs is not None:
            quantities += objs

    if verbose:
        root.level = level

    return quantities
572555
def parse(text):
        
        try:
            return int(text)
        except ValueError:
            try:
                amount = float(text)
                assert not isnan(amount) and not isinf(amount)
                return amount
            except (ValueError, AssertionError):
                return None
722349
def parse(self, text):
        """"""
        self.expr = text
        try:
            out = ast.parse(text)
        except SyntaxError:
            self.raise_exception(None, msg='Syntax Error', expr=text)
        except:
            self.raise_exception(None, msg='Runtime Error', expr=text)

        return out
1232461
def parse(self, format_string):
        """"""
        txt, state = '', 0
        colorstack = [(None, None)]
        itokens = self.tokenize(format_string)

        for token, escaped in itokens:
            if token == self._START_TOKEN and not escaped:
                if txt:
                    yield txt, colorstack[-1]
                    txt = ''

                state += 1
                colors = self.extract_syntax(colorise.compat.next(itokens)[0])
                colorstack.append(tuple(b or a
                                        for a, b in zip(colorstack[-1],
                                                        colors)))
            elif token == self._FMT_TOKEN and not escaped:
                # if state == 0:
                #     raise ColorSyntaxError("Missing '{0}'"
                #                            .format(self._START_TOKEN))

                if state % 2 != 0:
                    state += 1
                else:
                    txt += token
            elif token == self._STOP_TOKEN and not escaped:
                if state < 2:
                    raise ColorSyntaxError("Missing '{0}' or '{1}'"
                                           .format(self._STOP_TOKEN,
                                                   self._FMT_TOKEN))

                if txt:
                    yield txt, colorstack[-1]
                    txt = ''

                state -= 2
                colorstack.pop()
            else:
                txt += token

        if state != 0:
            raise ColorSyntaxError("Invalid color format")

        if txt:
            yield txt, colorstack[-1]
598538
def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
        
        return stream_rdr.read_str(value_count-1, value_offset)
354885
def unpack(self, format_text):
        
        data = _unpack_from(format_text, self.data, self.offset)
        self.offset += _calcsize(format_text)
        return data
1260155
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    private static SortedSet<MediaType> parse(final String text) {
        final SortedSet<MediaType> list = new TreeSet<>();
        for (final String name
            : new EnglishLowerCase(text).string().split(",")) {
            if (!name.isEmpty()) {
                list.add(new MediaType(name));
            }
        }
        return list;
    }
1311459
def from_string(self, value):
        """"""
        # Remove optional []
        if value.startswith('[') and value.endswith(']'):
            text = value[1:-1].strip()
        else:
            text = value.strip()
        # Result is a list
        result = []
        # If value starts with '(' assume a list of pairs
        if text.startswith('('):
            tokens = text.split(',')
            if len(tokens) % 2 != 0:
                raise ValueError('not a valid list of pairs')
            pos = 0
            while (pos < len(tokens)):
                val1 = float(tokens[pos].strip()[1:].strip())
                val2 = float(tokens[pos + 1].strip()[:-1])
                result.append((val1, val2))
                pos += 2
        else:
            for val in text.split(','):
                result.append(float(val))
        # Ensure that the result contains at least two elements
        if len(result) < 2:
            raise ValueError('invalid number of elements in list: ' + str(len(result)))
        return result
619528
def parse(cls, text):
        
        OUTSIDE, IN_DOUBLE, IN_SINGLE = 0, 1, 2

        iterator = enumerate(text)
        state = OUTSIDE
        parts = []
        current_part = ''
        part_start_pos = 0

        for i, c in iterator:  # XXX: correctly handle empty strings.
            if state == OUTSIDE:
                if c.isspace():
                    # New part.
                    if current_part:
                        parts.append(current_part)
                    part_start_pos = i + 1
                    current_part = ''
                elif c == '"':
                    state = IN_DOUBLE
                elif c == "'":
                    state = IN_SINGLE
                else:
                    current_part += c

            elif state == IN_SINGLE:
                if c == "'":
                    state = OUTSIDE
                elif c == "\\":
                    next(iterator)
                    current_part += c
                else:
                    current_part += c

            elif state == IN_DOUBLE:
                if c == '"':
                    state = OUTSIDE
                elif c == "\\":
                    next(iterator)
                    current_part += c
                else:
                    current_part += c

        parts.append(current_part)
        return parts, part_start_pos
736126
public void parseLongestText(String text, AhoCorasickDoubleArrayTrie.IHit<V> processor)
    {
        int length = text.length();
        for (int i = 0; i < length; ++i)
        {
            BaseNode<V> state = transition(text.charAt(i));
            if (state != null)
            {
                int to = i + 1;
                int end = to;
                V value = state.getValue();
                for (; to < length; ++to)
                {
                    state = state.transition(text.charAt(to));
                    if (state == null) break;
                    if (state.getValue() != null)
                    {
                        value = state.getValue();
                        end = to + 1;
                    }
                }
                if (value != null)
                {
                    processor.hit(i, end, value);
                    i = end - 1;
                }
            }
        }
    }
738308
def parse_text(self,text):
        """"""
        try:
            return self.rProgram.ignore(cStyleComment).parseString(text, parseAll=True)
        except SemanticException as err:
            print(err)
            exit(3)
        except ParseException as err:
            print(err)
            exit(3)
660391
private static Long parseLong(final String text) {
		if (text.length() == 0) {
			return null;
		} else {
			try {
				return Long.parseLong(text);
			} catch (NumberFormatException ex) {
				return null;
			}
		}
	}