ProgressBar::write

Write progress bar.
432329
protected function write()
    {
        $this->updateSize();
        $this->writeStatus($this->units, $this->total, $this->columns, $this->columns);
    }
1111595
def log_progress(lbl='Progress: ', length=0, flushfreq=4, startafter=-1,
                 start=True, repl=False, approx=False, disable=False,
                 writefreq=1, with_time=False, backspace=True,
                 pad_stdout=False, wfreq=None, ffreq=None, freq=None, total=None,
                 num=None, with_totaltime=None):
    
    global AGGROFLUSH
    # Alias kwargs with simpler names
    if num is not None:
        length = num
    if total is not None:
        length = total
    if wfreq is not None:
        writefreq = wfreq
    if ffreq is not None:
        flushfreq = ffreq
    if freq is not None:
        writefreq = flushfreq = freq
    if with_totaltime is not None:
        with_time = with_totaltime
    # flush frequency must be a multiple of write frequency
    flushfreq = max(int(round(flushfreq / writefreq)), 1) * writefreq
    if length < startafter or disable:
        # Do not mark progress if only executing a small number of tasks
        def mark_progress(*args):
            pass
        def end_progress(*args):
            pass
        return mark_progress, end_progress
    else:
        write_fn = util_logging._utool_write()
        flush_fn = util_logging._utool_flush()
        # build format string for displaying progress
        fmt_str = progress_str(length, lbl=lbl, repl=repl, approx=approx,
                               backspace=backspace)
        if AGGROFLUSH:
            # Progress function which automatically flushes
            def mark_progress(count, flush_fn=flush_fn):
                count_ = count + 1
                write_fn(fmt_str % (count_))
                flush_fn()
        else:
            # Progress function flushes every <flushfreq> times
            def mark_progress(count, fmt_str=fmt_str, flushfreq=flushfreq,
                              writefreq=writefreq, write_fn=write_fn,
                              flush_fn=flush_fn):
                count_ = count + 1
                if count_ % writefreq == 0:
                    write_fn(fmt_str % count_)
                    if count_ % flushfreq == 0:
                        flush_fn()

        if pad_stdout:
            write_fn('\n')
            write_fn('\n')
            flush_fn()

        if with_time:
            tt = util_time.tic(lbl)

        def end_progress(count_=length, write_fn=write_fn, flush_fn=flush_fn):
            write_fn(fmt_str % (count_))
            write_fn('\n')
            flush_fn()
            if with_time:
                util_time.toc(tt)
            if pad_stdout:
                write_fn('\n\n')
                flush_fn()
        #mark_progress(0)
        if start:
            mark_progress(-1)
        return mark_progress, end_progress
440723
private function startProgressBar()
    {
        $this->output->newLine(1);
        $this->bar = $this->helper->barSetup($this->output->createProgressBar(5));
        $this->bar->start();
    }
838278
public function postRun(): void {
    if ($this->progress) {
      $this->progress->finish();
      // Progress bar does not print a new-line at the end.
      $this->getOutput()->writeln('');
    }
  }
1369140
def _initialize_progressbar(self):
        

        self._progressbar = progressbar.ProgressBar(widgets=Analysis._PROGRESS_WIDGETS, maxval=10000 * 100).start()
373462
protected function writeProgress($status)
    {
        $this->resetJsonResult();

        switch ($status) {
            case self::MACRO_SKIPPED:
                $this->jsonResult['skipped'] = true;
                $output = $this->getProgressTemplate('green', '_', 'S');

                break;

            case self::MACRO_PASS:
                $this->jsonResult['pass'] = true;
                $output = $this->getProgressTemplate('green', '.', '+');

                break;

            case self::MACRO_FAILURE:
                $this->jsonResult['failure'] = true;
                $output = $this->getProgressTemplate('bg_red_fg_yellow', 'f', 'F');

                break;

            case self::MACRO_ERROR:
                $this->jsonResult['error'] = true;
                $output = $this->getProgressTemplate('bg_red_fg_white', 'e', 'E');

                break;

            case self::MACRO_WARNING:
                $this->jsonResult['warning'] = true;
                $output = $this->getProgressTemplate('bg_yellow_fg_black', 'w', 'W');

                break;

            default:
                $this->jsonResult['unknown'] = true;
                $output = $output = $this->getProgressTemplate('bg_yellow_fg_black', '?', '?');

                break;
        }

        $this->write($output);
    }
823707
def write(self, fp):
        """"""
        if self._defaults:
            fp.write("[%s]\n" % DEFAULTSECT)
            for (key, value) in self._defaults.items():
                fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
            fp.write("\n")
        for section in self._sections:
            fp.write("[%s]\n" % section)
            for (key, value) in self._sections[section].items():
                if key == "__name__":
                    continue
                if (value is not None) or (self._optcre == self.OPTCRE):
                    key = " = ".join((key, str(value).replace('\n', '\n\t')))
                fp.write("%s\n" % (key))
            fp.write("\n")
1241328
def write(self, s):
        
        should_write_s = os.getenv('PROGRESSIVE_NOWRITE') != "True"
        if should_write_s:
            self._stream.write(s)
1334009
def write(self, data):
    """"""
    self._buffer.append(data)
    self._current_ticks += 1
    # first entry ever will be flushed immediately

    flush=False
    if self._last_flush_time is None or \
                (self._holdback_time is None and self._max_ticks == 0):
      flush = True
    elif self._max_ticks and self._current_ticks >= self._max_ticks or \
         self._holdback_time and time() - self._holdback_time >= self._last_flush_time:
      flush=True

    if flush:
      self.flush()
603697
def write(self):
        """"""
        with open(self.path, 'w') as f:
            self.config.write(f)
655537
def _write(self, data):
        """"""
        stream = yaml.dump(data, default_flow_style=False)
        self.path.write_text(stream)
1137668
def _writen(fd, data):
    """"""
    while data:
        n = os.write(fd, data)
        data = data[n:]
1320494
def write(self, handle):
        """"""
        handle.write(u"\t".join(self.columns))
        handle.write(u"\n")
        for row in self.rows:
            row.write(handle)
984226
public function progressBarCommand(): void
    {
        $i     = 0;
        $total = 120;
        $bar   = new ProgressBar();
        $bar->start(120);

        while ($i <= $total) {
            $bar->advance();
            usleep(50000);
            $i++;
        }

        $bar->finish();
    }
520293
def print_progress_bar(self, task):
        
        str_format = "{0:." + str(task.decimals) + "f}"
        percents = str_format.format(100 * (task.progress / float(task.total)))
        filled_length = int(round(task.bar_length * task.progress / float(task.total)))
        bar = '█' * filled_length + '-' * (task.bar_length - filled_length)

        # Build elapsed time if needed
        elapsed_time = None

        if task.display_time:
            if task.end_time:
                # If the task has ended, stop the chrono
                if not task.elapsed_time_at_end:
                    task.elapsed_time_at_end = self.millis_to_human_readable(task.end_time - task.begin_time)
                elapsed_time = task.elapsed_time_at_end
            else:
                # If task is new then start the chrono
                if not task.begin_time:
                    task.begin_time = millis()
                elapsed_time = self.millis_to_human_readable(millis() - task.begin_time)

        prefix_pattern = '%{}s'.format(self.longest_bar_prefix_size)
        time_container_pattern = '(%s)' if task.display_time and not task.end_time else '[%s]'

        if len(task.suffix) > 0 and task.display_time:
            sys.stdout.write('\n {} |%s| %3s %% {} - %s'.format(prefix_pattern, time_container_pattern)
                             % (task.prefix, bar, percents, elapsed_time, task.suffix))
        elif len(task.suffix) > 0 and not task.display_time:
            sys.stdout.write('\n {} |%s| %3s %% - %s'.format(prefix_pattern)
                             % (task.prefix, bar, percents, task.suffix))
        elif task.display_time and not len(task.suffix) > 0:
            sys.stdout.write('\n {} |%s| %3s %% {}'.format(prefix_pattern, time_container_pattern)
                             % (task.prefix, bar, percents, elapsed_time))
        else:
            sys.stdout.write('\n {} |%s| %3s %%'.format(prefix_pattern)
                             % (task.prefix, bar, percents))

        sys.stdout.write('\n')
        sys.stdout.flush()
1225466
def flush(self, draw_progress=True):
    """"""
    reset_progressbar = None
    if self._draw_progressbar and draw_progress:
      progressbar, reset_progressbar = self._draw_progressbar()
      self._buffer.append(progressbar)

    for line in self._buffer:
      self._outFile.write(line)
    #self._outFile.flush() needed?
    self._buffer = []
    if reset_progressbar:
      # first thing on next flush is to reset the current progressbar
      self._buffer.append(reset_progressbar)
    self._current_ticks = 0
    self._last_flush_time = time()
576318
public function update_progress() {
        // If finished...
        if (!$this->is_in_progress_section()) {
            if ($this->bar) {
                $this->end_html();
            }
        } else {
            if (!$this->bar) {
                $this->start_html();
            }
            // In case of indeterminate or small progress, update the wibbler
            // (up to once per second).
            if (time() != $this->lastwibble) {
                $this->lastwibble = time();
                echo \html_writer::div('', 'wibble state' . $this->currentstate);

                // Go on to next colour.
                $this->currentstate += $this->direction;
                if ($this->currentstate < 0 || $this->currentstate >= self::WIBBLE_STATES) {
                    $this->direction = -$this->direction;
                    $this->currentstate += 2 * $this->direction;
                }
                $buffersize = ini_get('output_buffering');
                if (!is_numeric($buffersize)) {
                    // The output_buffering setting can be a number, but can also be "On" or "Off".
                    // If "Off", there's no buffer, if "On", there's no limit to the size. In either case,
                    // there's no point in trying to fill the buffer.
                    $buffersize = 0;
                }
                if ($buffersize) {
                    // Force the buffer full.
                    echo str_pad('', $buffersize);
                }
            }

            // Get progress.
            list ($min, $max) = $this->get_progress_proportion_range();

            // Update progress bar.
            $message = '';
            if ($this->displaynames) {
                $message = $this->get_current_description();
            }
            $this->bar->update_full($min * 100, $message);

            // Flush output.
            flush();
        }
    }