Find the `expected` line within `times` trials.

        Args:
            expected    str: the expected string
            times       int: number of trials
515276
def _expect(self, expected, times=50):
        
        print '[%s] Expecting [%s]' % (self.port, expected)

        retry_times = 10
        while times > 0 and retry_times > 0:
            line = self._readline()
            print '[%s] Got line [%s]' % (self.port, line)

            if line == expected:
                print '[%s] Expected [%s]' % (self.port, expected)
                return

            if not line:
                retry_times -= 1
                time.sleep(0.1)

            times -= 1

        raise Exception('failed to find expected string[%s]' % expected)
615301
private void checkLineBeginsWith(String line, String expect, int lineCount) throws CDKException {
        if (line == null) {
            throw new CDKException("RGFile invalid, empty/null line at #" + lineCount);
        }
        if (!line.startsWith(expect)) {
            throw new CDKException("RGFile invalid, line #" + lineCount + " should start with:" + expect + ".");
        }
    }
6660
def waitVanish(self, pattern, seconds=None):
        
        r = self.clipRegionToScreen()
        if r is None:
            raise ValueError("Region outside all visible screens")
            return None
        if seconds is None:
            seconds = self.autoWaitTimeout
        if not isinstance(pattern, Pattern):
            if not isinstance(pattern, basestring):
                raise TypeError("find expected a string [image path] or Pattern object")
            pattern = Pattern(pattern)

        needle = cv2.imread(pattern.path)
        match = True
        timeout = time.time() + seconds

        while match and time.time() < timeout:
            matcher = TemplateMatcher(r.getBitmap())
            # When needle disappears, matcher returns None
            match = matcher.findBestMatch(needle, pattern.similarity)
            time.sleep(1/self._defaultScanRate if self._defaultScanRate is not None else 1/Settings.WaitScanRate)
        if match:
            return False
612811
def iterlines(s):
    
    prevnl = -1
    while True:
        nextnl = s.find('\n', prevnl + 1)
        if nextnl < 0:
            yield s[(prevnl+1):]
            break
        else:
            yield s[(prevnl+1):nextnl]
            prevnl = nextnl
164133
def next(self, now=None, increments=_increments, delta=True, default_utc=WARN_CHANGE):
        '''
        
        '''
        if default_utc is WARN_CHANGE and (isinstance(now, _number_types) or (now and not now.tzinfo) or now is None):
            warnings.warn(WARNING_CHANGE_MESSAGE, FutureWarning, 2)
            default_utc = False

        now = now or (datetime.utcnow() if default_utc and default_utc is not WARN_CHANGE else datetime.now())
        if isinstance(now, _number_types):
            now = datetime.utcfromtimestamp(now) if default_utc else datetime.fromtimestamp(now)

        # handle timezones if the datetime object has a timezone and get a
        # reasonable future/past start time
        onow, now = now, now.replace(tzinfo=None)
        tz = onow.tzinfo
        future = now.replace(microsecond=0) + increments[0]()
        if future < now:
            # we are going backwards...
            _test = lambda: future.year < self.matchers.year
            if now.microsecond:
                future = now.replace(microsecond=0)
        else:
            # we are going forwards
            _test = lambda: self.matchers.year < future.year

        # Start from the year and work our way down. Any time we increment a
        # higher-magnitude value, we reset all lower-magnitude values. This
        # gets us performance without sacrificing correctness. Still more
        # complicated than a brute-force approach, but also orders of
        # magnitude faster in basically all cases.
        to_test = ENTRIES - 1
        while to_test >= 0:
            if not self._test_match(to_test, future):
                inc = increments[to_test](future, self.matchers)
                future += inc
                for i in xrange(0, to_test):
                    future = increments[ENTRIES+i](future, inc)
                try:
                    if _test():
                        return None
                except:
                    print(future, type(future), type(inc))
                    raise
                to_test = ENTRIES-1
                continue
            to_test -= 1

        # verify the match
        match = [self._test_match(i, future) for i in xrange(ENTRIES)]
        _assert(all(match),
            "\nYou have discovered a bug with crontab, please notify the\n" \
            "author with the following information:\n" \
            "crontab: %r\n" \
            "now: %r", ' '.join(m.input for m in self.matchers), now)

        if not delta:
            onow = now = datetime(1970, 1, 1)

        delay = future - now
        if tz:
            delay += _fix_none(onow.utcoffset())
            if hasattr(tz, 'localize'):
                delay -= _fix_none(tz.localize(future).utcoffset())
            else:
                delay -= _fix_none(future.replace(tzinfo=tz).utcoffset())

        return delay.days * 86400 + delay.seconds + delay.microseconds / 1000000.
781494
function(time) {
          if (this._queue.length === 0) return
          var i = 0, line, oldLines
          while ((line = this._queue[i++]) && time >= line.t2) 1
          oldLines = this._queue.slice(0, i - 1)
          this._queue = this._queue.slice(i - 1)
          if (this._queue.length === 0)
            this._lastValue = oldLines[oldLines.length - 1].v2
        }
522854
def count(start=0, step=1, *, interval=0):
    
    agen = from_iterable.raw(itertools.count(start, step))
    return time.spaceout.raw(agen, interval) if interval else agen
60686
def expects(self, prop):
        
        expectation = SinonExpectation(self.obj, prop)
        self.exp_list.append(expectation)
        return expectation
126648
def times(p, mint, maxt=None):
    ''''''
    maxt = maxt if maxt else mint

    @Parser
    def times_parser(text, index):
        cnt, values, res = 0, Value.success(index, []), None
        while cnt < maxt:
            res = p(text, index)
            if res.status:
                values = values.aggregate(
                    Value.success(res.index, [res.value]))
                index, cnt = res.index, cnt + 1
            else:
                if cnt >= mint:
                    break
                else:
                    return res  # failed, throw exception.
            if cnt >= maxt:  # finish.
                break
            # If we don't have any remaining text to start next loop, we need break.
            #
            # We cannot put the `index < len(text)` in where because some parser can
            # success even when we have no any text. We also need to detect if the
            # parser consume no text.
            #
            # See: #28
            if index >= len(text):
                if cnt >= mint:
                    break  # we already have decent result to return
                else:
                    r = p(text, index)
                    if index != r.index:  # report error when the parser cannot success with no text
                        return Value.failure(index, "already meets the end, no enough text")
        return values
    return times_parser
101952
def expected_runtime_seconds(report_count:)
      runs = report_count * options[:lines_multipliers].length
      warmup_time_seconds = runs * options[:benchmark_warmup]
      bench_time_seconds = runs * options[:benchmark_time]

      warmup_time_seconds + bench_time_seconds
    end
1089464
def get_timerange(self, start, end, code=None):
        
        try:
            return self.data.loc[(slice(pd.Timestamp(start), pd.Timestamp(end)), slice(code)), :]
        except:
            return ValueError('CANNOT FOUND THIS TIME RANGE')
151798
def hit(self, code, line, duration):
        
        entry = self.line_dict[line][code]
        entry[0] += 1
        entry[1] += duration
484454
def rspr(self, times=1, **kwargs):
        

        spr = SPR(self.copy())
        for _ in range(times):
            spr.rspr(**kwargs)
        return spr.tree
730446
def _get_next_time(lines: [dict], target: str) -> str:  # type: ignore
    
    for line in lines:
        if line[target] and not _is_tempo_or_prob(line['type']):
            return line[target]
    return ''
74076
function() {
          var methodString = 'expected ' + object.toString() + '.' + method + '()' + (negate ? ' not' : '' )
          
          function times(n) {
            return n > 2 ?  n + ' times' : { 1: 'once', 2: 'twice' }[n]
          }
          
          if (this.expectedResult != null && (negate ? this.anyResultsPass() : this.anyResultsFail()))
            this.message = methodString + ' to return ' + puts(this.expectedResult) + 
              ' but ' + (negate ? 'it did' : 'got ' + puts(this.failingResult())) 

          if (this.expectedArgs && (negate ? !this.expectedResult && this.anyArgsPass() : this.anyArgsFail()))
            this.message = methodString + ' to be called with ' + puts.apply(this, this.expectedArgs) +
             ' but was' + (negate ? '' : ' called with ' + puts.apply(this, this.failingArgs()))

          if (negate ? !this.expectedResult && !this.expectedArgs && this.calls.length >= this.times : this.calls.length != this.times)
            this.message = methodString + ' to be called ' + times(this.times) + 
            ', but ' +  (this.calls.length == 0 ? ' was not called' : ' was called ' + times(this.calls.length))
                
          if (!this.message.length) 
            this.passed = true
          
          return this
        }
1187453
def find_missing_taf_times(lines: [dict], start: Timestamp, end: Timestamp) -> [dict]:  # type: ignore
    
    if not lines:
        return lines
    # Assign start time
    lines[0]['start_time'] = start
    # Fix other times
    last_fm_line = 0
    for i, line in enumerate(lines):
        if _is_tempo_or_prob(line['type']):
            continue
        last_fm_line = i
        # Search remaining lines to fill empty end or previous for empty start
        for target, other, direc in (('start', 'end', -1), ('end', 'start', 1)):
            target += '_time'
            if not line[target]:
                line[target] = _get_next_time(lines[i::direc][1:], other + '_time')
    # Special case for final forcast
    if last_fm_line:
        lines[last_fm_line]['end_time'] = end
    # Reset original end time if still empty
    if lines and not lines[0]['end_time']:
        lines[0]['end_time'] = end
    return lines
285334
def rept(ctx, text, number_times):
    
    if number_times < 0:
        raise ValueError("Number of times can't be negative")
    return conversions.to_string(text, ctx) * conversions.to_integer(number_times, ctx)