Actual parser. Please note that time_to is not required to process as not all subtitles
        provide it.
189323
def __parseFormat(self, fmt, content, fps = 25):
        ''''''

        headerFound = False
        subSection = ''
        for lineNo, line in enumerate(content):
            line = self._initialLinePrepare(line, lineNo)
            if not fmt.WITH_HEADER and not self._formatFound and lineNo > self._maxFmtSearch:
                return

            subSection = ''.join([subSection, line])
            if fmt.WITH_HEADER and not headerFound:
                if lineNo > self._maxHeaderLen:
                    return
                headerFound = fmt.addHeaderInfo(subSection, self._subtitles.header())
                if headerFound:
                    self._formatFound = True
                    subSection = ''
            elif fmt.subtitleEnds(line) or (lineNo + 1) == len(content):
                subtitle = fmt.createSubtitle(fps, subSection)
                if subtitle is None:
                    if subSection in ('\n', '\r\n', '\r'):
                        subSection = ''
                        continue
                    elif self._subtitles.size() > 0:
                        raise SubParsingError(_("Parsing error"), lineNo)
                    else:
                        return

                # store parsing result if new end marker occurred, then clear results
                if subtitle.start and subtitle.text:
                    self._formatFound = True
                    try:
                        self._subtitles.append(subtitle)
                    except SubException as msg:
                        raise SubParsingError(msg, lineNo)
                elif subtitle.start and not subtitle.text:
                    pass
                else:
                    return
                subSection = ''
277202
def parser(self):
        '''
        
        '''
        if not hasattr(self, '_parser'):
            self._parser = self._compile()
        return self._parser
1315897
def parse(self, input):
        
        result = self._parseIso8601(input)
        if not result:
            result = self._parseSimple(input)
        if result is not None:
            return result
        else:
            raise ParameterException("Invalid time delta - could not parse %s" % input)
5054
def _parse_data(self, raw_data, var_filter, time_extents):
        

        retval = defaultdict(list)
        p = parser()

        begin_time, end_time = time_extents

        for line in raw_data.splitlines():
            if len(line) == 0:
                continue

            fields = line.split("|")[0:-1]
            if var_filter is None or fields[2] in var_filter:
                dt = p.parse(fields[3]).replace(tzinfo=pytz.utc)
                if (begin_time is None or dt >= begin_time) and (
                    end_time is None or dt <= end_time
                ):
                    try:
                        value = (
                            float(fields[4]) if fields[4] != "NaN" else npNan
                        )
                    except ValueError:
                        value = npNan
                    retval[fields[0]].append((fields[2], dt, value))

        return dict(retval)
187505
def datetime_parsing(text, base_date=datetime.now()):
    
    matches = []
    found_array = []

    # Find the position in the string
    for expression, function in regex:
        for match in expression.finditer(text):
            matches.append((match.group(), function(match, base_date), match.span()))

    # Wrap the matched text with TAG element to prevent nested selections
    for match, value, spans in matches:
        subn = re.subn(
            '(?!<TAG[^>]*?>)' + match + '(?![^<]*?</TAG>)', '<TAG>' + match + '</TAG>', text
        )
        text = subn[0]
        is_substituted = subn[1]
        if is_substituted != 0:
            found_array.append((match, value, spans))

    # To preserve order of the match, sort based on the start position
    return sorted(found_array, key=lambda match: match and match[2][0])
606223
def get_sents_times_and_translations(xml_fn):
    

    tree = ElementTree.parse(xml_fn)
    root = tree.getroot()
    if "WORDLIST" in root.tag or root.tag == "TEXT":
        transcriptions = []
        times = []
        translations = []
        for child in root:
            # If it's a sentence or a word (this will be dictated by root_tag)
            if child.tag == "S" or child.tag == "W":
                forms = child.findall("FORM")
                if len(forms) > 1:
                    # Assuming there is kindOf="phono" available.
                    for form in forms:
                        if form.attrib["kindOf"] == "phono":
                            transcription = form.text
                else:
                    transcription = child.find("FORM").text
                audio_info = child.find("AUDIO")
                if audio_info is not None:
                    start_time = float(audio_info.attrib["start"])
                    end_time = float(audio_info.attrib["end"])
                    time = (start_time, end_time)
                    translation = [trans.text for trans in child.findall("TRANSL")]
                    transcriptions.append(transcription)
                    times.append(time)
                    translations.append(translation)

        return root.tag, transcriptions, times, translations
    logger.critical('the root tag, %s, does not contain "WORDLIST", and is not "TEXT"', root.tag)
    assert False, root.tag
999148
function de__processRelativeTime(number, withoutSuffix, key, isFuture) {
        var format = {
            'm': ['eine Minute', 'einer Minute'],
            'h': ['eine Stunde', 'einer Stunde'],
            'd': ['ein Tag', 'einem Tag'],
            'dd': [number + ' Tage', number + ' Tagen'],
            'M': ['ein Monat', 'einem Monat'],
            'MM': [number + ' Monate', number + ' Monaten'],
            'y': ['ein Jahr', 'einem Jahr'],
            'yy': [number + ' Jahre', number + ' Jahren']
        };
        return withoutSuffix ? format[key][0] : format[key][1];
    }
1268203
def create_time_parser
      if @time_key_format
        begin
          # Strptime doesn't support all formats, but for those it does it's
          # blazingly fast.
          strptime = Strptime.new(@time_key_format)
          Proc.new { |value|
            value = convert_numeric_time_into_string(value, @time_key_format) if value.is_a?(Numeric)
            strptime.exec(value).to_datetime
          }
        rescue
          # Can happen if Strptime doesn't recognize the format; or
          # if strptime couldn't be required (because it's not installed -- it's
          # ruby 2 only)
          Proc.new { |value|
            value = convert_numeric_time_into_string(value, @time_key_format) if value.is_a?(Numeric)
            DateTime.strptime(value, @time_key_format)
          }
        end
      else
        Proc.new { |value|
          value = convert_numeric_time_into_string(value) if value.is_a?(Numeric)
          DateTime.parse(value)
        }
      end
    end
1084875
def _parse_timeframe_line(self, line):
        """"""
        tf = self._validate_timeframe_line(line)
        if not tf:
            raise MalformedCaptionError('Invalid time format')

        return tf.group(1), tf.group(2)
1195715
def _parse(text, **options):
    
    # Handling special cases
    if text == "now":
        return pendulum.now()

    parsed = base_parse(text, **options)

    if isinstance(parsed, datetime.datetime):
        return pendulum.datetime(
            parsed.year,
            parsed.month,
            parsed.day,
            parsed.hour,
            parsed.minute,
            parsed.second,
            parsed.microsecond,
            tz=parsed.tzinfo or options.get("tz", UTC),
        )

    if isinstance(parsed, datetime.date):
        return pendulum.date(parsed.year, parsed.month, parsed.day)

    if isinstance(parsed, datetime.time):
        return pendulum.time(
            parsed.hour, parsed.minute, parsed.second, parsed.microsecond
        )

    if isinstance(parsed, _Interval):
        if parsed.duration is not None:
            duration = parsed.duration

            if parsed.start is not None:
                dt = pendulum.instance(parsed.start, tz=options.get("tz", UTC))

                return pendulum.period(
                    dt,
                    dt.add(
                        years=duration.years,
                        months=duration.months,
                        weeks=duration.weeks,
                        days=duration.remaining_days,
                        hours=duration.hours,
                        minutes=duration.minutes,
                        seconds=duration.remaining_seconds,
                        microseconds=duration.microseconds,
                    ),
                )

            dt = pendulum.instance(parsed.end, tz=options.get("tz", UTC))

            return pendulum.period(
                dt.subtract(
                    years=duration.years,
                    months=duration.months,
                    weeks=duration.weeks,
                    days=duration.remaining_days,
                    hours=duration.hours,
                    minutes=duration.minutes,
                    seconds=duration.remaining_seconds,
                    microseconds=duration.microseconds,
                ),
                dt,
            )

        return pendulum.period(
            pendulum.instance(parsed.start, tz=options.get("tz", UTC)),
            pendulum.instance(parsed.end, tz=options.get("tz", UTC)),
        )

    if CDuration and isinstance(parsed, CDuration):
        return pendulum.duration(
            years=parsed.years,
            months=parsed.months,
            weeks=parsed.weeks,
            days=parsed.days,
            hours=parsed.hours,
            minutes=parsed.minutes,
            seconds=parsed.seconds,
            microseconds=parsed.microseconds,
        )

    return parsed
1050982
def __result_parser(self, analyzed_line, is_feature, is_surface):
        # type: (text_type,bool,bool)->TokenizedResult
        
        assert isinstance(analyzed_line, str)
        assert isinstance(is_feature, bool)
        assert isinstance(is_surface, bool)

        surface, features = analyzed_line.split('\t', 1)
        tuple_pos, word_stem = self.__feature_parser(features, surface)
        tokenized_obj = TokenizedResult(
            node_obj=None,
            analyzed_line=analyzed_line,
            tuple_pos=tuple_pos,
            word_stem=word_stem,
            word_surface=surface,
            is_feature=is_feature,
            is_surface=is_surface
        )
        return tokenized_obj
871653
def _wrap_callback_parse_time_info(subscription, on_data, message):
    
    if message.type == message.REPLY:
        time_response = web_pb2.TimeSubscriptionResponse()
        time_response.ParseFromString(message.reply.data)
        time = parse_isostring(time_response.timeInfo.currentTimeUTC)
        #pylint: disable=protected-access
        subscription._process(time)
        if on_data:
            on_data(time)
    elif message.type == message.DATA:
        if message.data.type == yamcs_pb2.TIME_INFO:
            time_message = getattr(message.data, 'timeInfo')
            time = parse_isostring(time_message.currentTimeUTC)
            #pylint: disable=protected-access
            subscription._process(time)
            if on_data:
                on_data(time)
1101116
def parse(input):
    '''
    
    '''
    if isinstance(input, datetime):
        return input
    if isinstance(input, date):
        return date_to_datetime(input)
    if isinstance(input, time):
        return time_to_datetime(input)
    if isinstance(input, (int, float)):
        return timestamp_to_datetime(input)
    if isinstance(input, (str)):
        return string_to_data_time(input)
    return None
994666
def parse(self, filename: str, language: str = None, contents: str = None,
              timeout: float = None) -> CompatParseResponse:

        

        return self._parse(filename, language, contents, timeout,
                           Mode.Value('ANNOTATED'))
293776
def _parse_time(self, time):
        """"""
        if time is None:
            return None

        if isinstance(time, dict):
            if 'column' not in time:
                raise ValueError("`time` must include a 'column' key/value")
            time_column = time['column']
            time_options = time
        elif isinstance(time, str):
            time_column = time
            time_options = {}
        else:
            raise ValueError(
                '`time` should be a column name or dictionary of '
                'styling options.')

        self.style_cols[time_column] = None
        time = {
            'column': time_column,
            'method': 'count',
            'cumulative': False,
            'frames': 256,
            'duration': 30,
            'trails': 2,
        }
        time.update(time_options)
        return time
887333
def temporal_from_literal(text):
    '''
    
    '''
    if text.count('/') == 1:
        # This is an ISO date range as preconized by Gov.uk
        # http://guidance.data.gov.uk/dcat_fields.html
        start, end = text.split('/')
        return db.DateRange(
            start=parse_dt(start).date(),
            end=parse_dt(end).date()
        )
    else:
        separators = text.count('-')
        if separators == 0:
            # this is a year
            return db.DateRange(
                start=date(int(text), 1, 1),
                end=date(int(text), 12, 31)
            )
        elif separators == 1:
            # this is a month
            dt = parse_dt(text).date()
            return db.DateRange(
                start=dt.replace(day=1),
                end=dt.replace(day=calendar.monthrange(dt.year, dt.month)[1])
            )
19835
def some(pred):
    

    @Parser
    def _some(tokens, s):
        if s.pos >= len(tokens):
            raise NoParseError(u'no tokens left in the stream', s)
        else:
            t = tokens[s.pos]
            if pred(t):
                pos = s.pos + 1
                s2 = State(pos, max(pos, s.max))
                if debug:
                    log.debug(u'*matched* "%s", new state = %s' % (t, s2))
                return t, s2
            else:
                if debug:
                    log.debug(u'failed "%s", state = %s' % (t, s))
                raise NoParseError(u'got unexpected token', s)

    _some.name = u'(some)'
    return _some