>>> print humanize(0)
    now
    >>> print humanize(1)
    in a minute
    >>> print humanize(60)
    in a minute
    >>> print humanize(61)
    in 2 minutes
    >>> print humanize(3600)
    in an hour
    >>> print humanize(3601)
    in 2 hours
3572
def humanize(t):
    
    m, s = divmod(t, 60)
    if s:
        m += 1                 # ceil minutes 
    h, m = divmod(m, 60)
    if m and h:
        h += 1                 # ceil hours
#    d, h = divmod(h, 24)

    if h > 1:
        res = 'in %d hours' % h
    elif h == 1:
        res = 'in an hour'
    else:
        if m > 1:
            res = 'in %d minutes' % m
        elif m == 1:
            res = 'in a minute'
        else:
            res = 'now'
    return res
1002974
def human_time(timespan, precision=3):
    """"""

    if timespan >= 60.0:
        # Format time greater than one minute in a human-readable format
        # Idea from http://snipplr.com/view/5713/
        def _format_long_time(time):
            suffixes = ('d', 'h', 'm', 's')
            lengths = (24*60*60, 60*60, 60, 1)

            for suffix, length in zip(suffixes, lengths):
                value = int(time / length)

                if value > 0:
                    time %= length
                    yield '%i%s' % (value, suffix)

                if time < 1:
                    break

        return ' '.join(_format_long_time(timespan))

    else:
        units = ['s', 'ms', 'us', 'ns']

        # Attempt to replace 'us' with 'µs' if UTF-8 encoding has been set
        if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding == 'UTF-8':
            try:
                units[2] = b'\xc2\xb5s'.decode('utf-8')
            except UnicodeEncodeError:
                pass

        scale = [1.0, 1e3, 1e6, 1e9]

        if timespan > 0.0:
            # Determine scale of timespan (s = 0, ms = 1, µs = 2, ns = 3)
            order = min(-int(math.floor(math.log10(timespan)) // 3), 3)
        else:
            order = 3

        return '%.*g %s' % (precision, timespan * scale[order], units[order])
516651
function humanizer (passedOptions) {
    var result = function humanizer (ms, humanizerOptions) {
      var options = extend({}, result, humanizerOptions || {})
      return doHumanization(ms, options)
    }

    return extend(result, {
      language: 'en',
      delimiter: ', ',
      spacer: ' ',
      conjunction: '',
      serialComma: true,
      units: ['y', 'mo', 'w', 'd', 'h', 'm', 's'],
      languages: {},
      round: false,
      unitMeasures: {
        y: 31557600000,
        mo: 2629800000,
        w: 604800000,
        d: 86400000,
        h: 3600000,
        m: 60000,
        s: 1000,
        ms: 1
      }
    }, passedOptions)
  }
38743
def print_time(self, message="Time is now: ", print_frame_info=True):
        
        if print_frame_info:
            frame_info = inspect.getouterframes(inspect.currentframe())[1]
            print(message, (datetime.now() - self.start_time), frame_info)
        else:
            print(message, (datetime.now() - self.start_time))
1321776
def pprint(self, num=10):
        
        def takeAndPrint(time, rdd):
            taken = rdd.take(num + 1)
            print("-------------------------------------------")
            print("Time: %s" % time)
            print("-------------------------------------------")
            for record in taken[:num]:
                print(record)
            if len(taken) > num:
                print("...")
            print("")

        self.foreachRDD(takeAndPrint)
181382
def printer(self):
        """"""
        print " ID " + repr(self.id)
        if self.type == 0:
            print " Tag: - "
            print " Start State - "
        elif self.type == 1:
            print " Push " + repr(self.sym)
        elif self.type == 2:
            print " Pop State " + repr(self.sym)
        elif self.type == 3:
            print " Read State " + repr(self.sym)
        elif self.type == 4:
            print " Stop State " + repr(self.sym)
        for j in self.trans:
            if len(self.trans[j]) > 1 or (len(self.trans[j]) == 1):
                for symbol in self.trans[j]:
                    print " On Symbol " + repr(symbol) + " Transition To State " + repr(j)
272819
def print_out(self, value, indent=None, format_options=None, asap=False):
        
        if indent is None:
            indent = '>   '

        text = indent + str(value)

        if format_options is None:
            format_options = 'gray'

        if self._style_prints and format_options:

            if not isinstance(format_options, dict):
                format_options = {'color_fg': format_options}

            text = format_print_text(text, **format_options)

        command = 'iprint' if asap else 'print'
        self._set(command, text, multi=True)

        return self
136362
def humanize_duration(duration):
    
    days = duration.days
    hours = int(duration.seconds / 3600)
    minutes = int(duration.seconds % 3600 / 60)
    seconds = int(duration.seconds % 3600 % 60)

    parts = []
    if days > 0:
        parts.append(u'%s %s' % (days, pluralize(days, _('day,days'))))

    if hours > 0:
        parts.append(u'%s %s' % (hours, pluralize(hours, _('hour,hours'))))

    if minutes > 0:
        parts.append(u'%s %s' % (minutes, pluralize(minutes, _('minute,minutes'))))

    if seconds > 0:
        parts.append(u'%s %s' % (seconds, pluralize(seconds, _('second,seconds'))))

    return ', '.join(parts) if len(parts) != 0 else _('< 1 second')
1322095
def print_one_train(client, verbosity=0):
    
    ts_before = time()
    data, meta = client.next()
    ts_after = time()

    if not data:
        print("Empty data")
        return

    train_id = list(meta.values())[0].get('timestamp.tid', 0)
    print("Train ID:", train_id, "--------------------------")
    delta = ts_after - ts_before
    print('Data from {} sources, REQ-REP took {:.2f} ms'
          .format(len(data), delta))
    print()

    for i, (source, src_data) in enumerate(sorted(data.items()), start=1):
        src_metadata = meta.get(source, {})
        tid = src_metadata.get('timestamp.tid', 0)
        print("Source {}: {!r} @ {}".format(i, source, tid))
        try:
            ts = src_metadata['timestamp']
        except KeyError:
            print("No timestamp")
        else:
            dt = strftime('%Y-%m-%d %H:%M:%S', localtime(ts))

            delay = (ts_after - ts) * 1000
            print('timestamp: {} ({}) | delay: {:.2f} ms'
                  .format(dt, ts, delay))

        if verbosity < 1:
            print("- data:", sorted(src_data))
            print("- metadata:", sorted(src_metadata))
        else:
            print('data:')
            pretty_print(src_data, verbosity=verbosity - 1)
            if src_metadata:
                print('metadata:')
                pretty_print(src_metadata)
        print()

    return data, meta
1205018
def pprint(self, seconds):
        
        return ("%d:%02d:%02d.%03d", reduce(lambda ll, b: divmod(ll[0], b) + ll[1:], [(seconds * 1000,), 1000, 60, 60]))
218109
function printTimingAndExit(startTime) {
  const execTime = time() - startTime;

  printColumns(chalk.green(`Finished in: ${execTime.toFixed()}ms`));
  process.exit(0);
}
1076235
@Override
    public int print(
        ChronoDisplay formattable,
        Appendable buffer,
        AttributeQuery attributes,
        Set<ElementPosition> positions, // optional
        boolean quickPath
    ) throws IOException {

        if (quickPath && this.optPrinter) {
            attributes = ChronoFormatter.class.cast(this.printer).getAttributes();
        }

        // special optimization avoiding double conversion from Moment to ZonalDateTime
        if (this.passThroughZDT && (formattable instanceof ZonalDateTime) && (positions == null)) {
            ChronoFormatter<?> cf = (ChronoFormatter<?>) this.printer;
            cf.print(formattable, buffer, attributes, false);
            return Integer.MAX_VALUE; // unknown number of printed characters
        }

        V value = formattable.get(this.element);
        StringBuilder collector = new StringBuilder();

        if ((positions != null) && (buffer instanceof CharSequence)) {
            int offset = ((CharSequence) buffer).length();

            if (this.printer instanceof ChronoFormatter) {
                ChronoFormatter<?> cf = ChronoFormatter.class.cast(this.printer);
                Set<ElementPosition> result = print(cf, value, collector, attributes);
                Set<ElementPosition> set = new LinkedHashSet<>();
                for (ElementPosition ep : result) {
                    set.add(
                        new ElementPosition(
                            ep.getElement(),
                            offset + ep.getStartIndex(),
                            offset + ep.getEndIndex()));
                }
                positions.addAll(set);
            } else {
                this.printer.print(value, collector, attributes);
            }

            positions.add(
                new ElementPosition(
                    this.element,
                    offset,
                    offset + collector.length()));
        } else {
            this.printer.print(value, collector, attributes);
        }

        buffer.append(collector);
        return collector.length();

    }
46232
def print_timer(self, timer_name, **kwargs):
        ''' 
        '''
        if hasattr(self, timer_name):
            _delete_timer = kwargs.get("delete", False)
            print("|-------- {} [Time Log Calculation]-----------------|".format(\
                    timer_name))
            print("StartDiff\tLastNodeDiff\tNodeName")
            time_log = getattr(self, timer_name)
            start_time = time_log[0]['time']
            previous_time = start_time
            for entry in time_log:
                time_diff = (entry['time'] - previous_time) *1000
                time_from_start = (entry['time'] - start_time) * 1000
                previous_time = entry['time']
                print("{:.1f}\t\t{:.1f}\t\t{}".format(time_from_start,
                                                      time_diff,
                                                      entry['node']))
            print("|--------------------------------------------------------|")
            if _delete_timer:
                self.delete_timer(timer_name)
1035233
def print(self, indent=0):
        """"""
        text = (
            '{indent}{magenta}{name}{none} ({dim}{cls}{none}, '
            'default {dim}{default}{none})'
        ).format(
            indent=' ' * indent,
            dim=Style.DIM,
            magenta=Fore.MAGENTA,
            none=Style.RESET_ALL,
            name=self.name,
            cls=self.cls,
            default=self.default
        )

        if self.description:
            text += ':\n' + pretty_description(self.description,
                                               indent=indent + 2)

        print(text)
643971
def dbg_print(self, indent=0):
        
        lst = []
        more_data = False
        for i, addr in enumerate(self.mem.keys()):
            lst.append(addr)
            if i >= 20:
                more_data = True
                break

        for addr in sorted(lst):
            data = self.mem[addr]
            if isinstance(data, SimMemoryObject):
                memobj = data
                print("%s%xh: (%s)[%d]" % (" " * indent, addr, memobj, addr - memobj.base))
            else:
                print("%s%xh: <default data>" % (" " * indent, addr))
        if more_data:
            print("%s..." % (" " * indent))
1135413
def print_benchmark(self):
        """"""
        print('%-7.2f %s' % (self.elapsed, 'seconds elapsed'))
        if self.elapsed:
            for key in self._benchmark_keys:
                print('%-7d %s per second (%d total)' %
                      (self.counters[key] / self.elapsed, key,
                       self.counters[key]))
1189678
def _print_stats(cls, stats: Statistics, human_format_speed: bool=True):
        ''''''
        time_length = datetime.timedelta(
            seconds=int(stats.stop_time - stats.start_time)
        )
        file_size = wpull.string.format_size(stats.size)

        if stats.bandwidth_meter.num_samples:
            speed = stats.bandwidth_meter.speed()

            if human_format_speed:
                speed_size_str = wpull.string.format_size(speed)
            else:
                speed_size_str = '{:.1f} b'.format(speed * 8)
        else:
            speed_size_str = _('-- B')

        _logger.info(_('FINISHED.'))
        _logger.info(__(
            _(
                'Duration: {preformatted_timedelta}. '
                'Speed: {preformatted_speed_size}/s.'
            ),
            preformatted_timedelta=time_length,
            preformatted_speed_size=speed_size_str,
        ))
        _logger.info(__(
            gettext.ngettext(
                'Downloaded: {num_files} file, {preformatted_file_size}.',
                'Downloaded: {num_files} files, {preformatted_file_size}.',
                stats.files
            ),
            num_files=stats.files,
            preformatted_file_size=file_size
        ))

        if stats.is_quota_exceeded:
            _logger.info(_('Download quota exceeded.'))