// StatLine calculates a simple statistics line suitable for logging.
342540
func (f *FileStats) StatLine(previous *FileStats, span time.Duration) string {
	var bytesDownloaded uint64
	if previous != nil {
		bytesDownloaded = f.BytesCompleted - previous.BytesCompleted
	}

	return fmt.Sprintf("Files (%d/%d) - %s / %s - %0.1f%% - %s/s",
		f.CountCompleted, f.CountScheduled,
		humanize.Bytes(f.BytesCompleted), humanize.Bytes(f.BytesScheduled),
		100*float64(f.BytesCompleted)/float64(f.BytesScheduled),
		humanize.Bytes(uint64(float64(bytesDownloaded)/span.Seconds())),
	)
}
333728
func NewInlineProgressInt(total int) *progress.Bar {
	b := progress.NewInt(total)
	b.Template(`{{.Bar}} {{.Percent | printf "%0.0f"}}% {{.Text}}`)
	b.Width = 20
	b.StartDelimiter = colors.Gray("|")
	b.EndDelimiter = colors.Gray("|")
	b.Filled = colors.Purple("█")
	b.Empty = colors.Gray(" ")
	return b
}
40139
func Line(buffer Buffer, event *cue.Event) {
	if len(event.Frames) == 0 {
		buffer.AppendString("0")
		return
	}
	buffer.AppendString(fmt.Sprintf("%d", event.Frames[0].Line))
}
570853
func (w Wrapper) line(s string, limit int) string {
	if limit < 1 || utf8.RuneCountInString(s) < limit+1 {
		return w.OutputLinePrefix + s + w.OutputLineSuffix
	}

	// Find the index of the last breakpoint within the limit.
	i := strings.LastIndexAny(s[:limit+1], w.Breakpoints)

	// Can't wrap within the limit, wrap at the next breakpoint instead.
	if i < 0 {
		i = strings.IndexAny(s, w.Breakpoints)
		// Nothing left to do!
		if i < 0 {
			return w.OutputLinePrefix + s + w.OutputLineSuffix
		}
	}

	// Recurse until we have nothing left to do.
	return w.OutputLinePrefix + s[:i] + w.OutputLineSuffix + w.Newline + w.line(s[i+1:], limit)
}
778403
func (ctx *compctx) ErrorLine() int {
	var n int
	fmt.Sscanf(ctx.Error(), "Error > stdin:%d", &n)
	return n
}
1273275
func Statter(s log.StatsReporter) Option {
	return func(r *Ringpop) error {
		r.statter = s
		return nil
	}
}
284652
func (u *UI) Line(format string, a ...interface{}) {
	u.LineIndent(0, format, a...)
}
579820
func (c *Command) UseLine() string {
	var useline string
	if c.HasParent() {
		useline = c.parent.CommandPath() + " " + c.Use
	} else {
		useline = c.Use
	}
	if c.DisableFlagsInUseLine {
		return useline
	}
	if c.HasAvailableFlags() && !strings.Contains(useline, "[flags]") {
		useline += " [flags]"
	}
	return useline
}
17828
func (ioctx *IOContext) Stat(object string) (stat ObjectStat, err error) {
	var c_psize C.uint64_t
	var c_pmtime C.time_t
	c_object := C.CString(object)
	defer C.free(unsafe.Pointer(c_object))

	ret := C.rados_stat(
		ioctx.ioctx,
		c_object,
		&c_psize,
		&c_pmtime)

	if ret < 0 {
		return ObjectStat{}, GetRadosError(int(ret))
	} else {
		return ObjectStat{
			Size:    uint64(c_psize),
			ModTime: time.Unix(int64(c_pmtime), 0),
		}, nil
	}
}
1181763
func countLines(output string) int {
	con, err := console.ConsoleFromFile(os.Stdin)
	if err != nil {
		return 0
	}
	ws, err := con.Size()
	if err != nil {
		return 0
	}
	width := int(ws.Width)
	if width <= 0 {
		return 0
	}
	strlines := strings.Split(output, "\n")
	lines := -1
	for _, line := range strlines {
		lines += (len(stripLine(line))-1)/width + 1
	}
	return lines
}
133316
func (p *Plan) Stats() PlanStats {
	var ret PlanStats
	for _, r := range p.Resources {
		switch r.Action {
		case plans.Create:
			ret.ToAdd++
		case plans.Update:
			ret.ToChange++
		case plans.DeleteThenCreate, plans.CreateThenDelete:
			ret.ToAdd++
			ret.ToDestroy++
		case plans.Delete:
			ret.ToDestroy++
		}
	}
	return ret
}
741424
func statReporter(statsUrl string, interval time.Duration) {

	tick := time.Tick(interval)
	for {
		select {
		case t := <-tick:
			collect(t, statsUrl)
		}
	}
}
376892
func (f *Fpdf) Line(x1, y1, x2, y2 float64) {
	f.outf("%.2f %.2f m %.2f %.2f l S", x1*f.k, (f.h-y1)*f.k, x2*f.k, (f.h-y2)*f.k)
}
1247353
func (as *Step) LogLine(label, line string) bool {
	updated := false

	name, ok := as.logLines[label]
	if !ok {
		// No entry for this log line. Create a new one and register it.
		//
		// This will appear as:
		// [BASE]/logs/[label]/[ord]
		subName, err := types.MakeStreamName("s_", "logs", label, strconv.Itoa(as.logLineCount[label]))
		if err != nil {
			panic(fmt.Errorf("failed to generate log stream name for [%s]: %s", label, err))
		}
		name = as.BaseStream(subName)
		as.AddLogdogStreamLink("", label, "", name)

		as.logLines[label] = name
		as.logLineCount[label]++
		updated = true
	}

	as.s.Callbacks.StepLogLine(as, name, label, line)
	return updated
}
132826
func (t *Table) printLine(nl bool) {
	fmt.Fprint(t.out, t.center(-1))
	for i := 0; i < len(t.cs); i++ {
		v := t.cs[i]
		fmt.Fprintf(t.out, "%s%s%s%s",
			t.pRow,
			strings.Repeat(string(t.pRow), v),
			t.pRow,
			t.center(i))
	}
	if nl {
		fmt.Fprint(t.out, t.newLine)
	}
}
1200850
func (c *Conn) printLine(cmd string, args ...interface{}) {
	io.WriteString(c.c.W, cmd)
	for _, a := range args {
		c.c.W.Write(space)
		fmt.Fprint(c.c.W, a)
	}
	c.c.W.Write(crnl)
}
1262675
func (diffSection *DiffSection) Line(lineType DiffLineType, idx int) *DiffLine {
	var (
		difference    = 0
		addCount      = 0
		delCount      = 0
		matchDiffLine *DiffLine
	)

LOOP:
	for _, diffLine := range diffSection.Lines {
		switch diffLine.Type {
		case DIFF_LINE_ADD:
			addCount++
		case DIFF_LINE_DEL:
			delCount++
		default:
			if matchDiffLine != nil {
				break LOOP
			}
			difference = diffLine.RightIdx - diffLine.LeftIdx
			addCount = 0
			delCount = 0
		}

		switch lineType {
		case DIFF_LINE_DEL:
			if diffLine.RightIdx == 0 && diffLine.LeftIdx == idx-difference {
				matchDiffLine = diffLine
			}
		case DIFF_LINE_ADD:
			if diffLine.LeftIdx == 0 && diffLine.RightIdx == idx+difference {
				matchDiffLine = diffLine
			}
		}
	}

	if addCount == delCount {
		return matchDiffLine
	}
	return nil
}