text stringlengths 0 828 |
|---|
420,"def format_progress(self, width): |
""""""Create the formatted string that displays the progress."""""" |
chunk_widths = self._get_chunk_sizes(width) |
progress_chunks = [chunk.format_chunk(chunk_width) |
for (chunk, chunk_width) |
in zip(self._progress_chunks, chunk_widths)] |
return ""{sep_start}{progress}{sep_end}"".format( |
sep_start=self.sep_start, |
progress="""".join(progress_chunks), |
sep_end=self.sep_end |
)" |
421,"def summary_width(self): |
""""""Calculate how long a string is needed to show a summary string. |
This is not simply the length of the formatted summary string |
since that string might contain ANSI codes. |
"""""" |
chunk_counts = [chunk.count for chunk in self._progress_chunks] |
numbers_width = sum(max(1, ceil(log10(count + 1))) |
for count in chunk_counts) |
separators_with = len(chunk_counts) - 1 |
return numbers_width + separators_with" |
422,"def format_summary(self): |
""""""Generate a summary string for the progress bar."""""" |
chunks = [chunk.format_chunk_summary() |
for chunk in self._progress_chunks] |
return ""/"".join(chunks)" |
423,"def add_progress(self, count, symbol='#', |
color=None, on_color=None, attrs=None): |
""""""Add a section of progress to the progressbar. |
The progress is captured by ""count"" and displayed as a fraction |
of the statusbar width proportional to this count over the total |
progress displayed. The progress will be displayed using the ""symbol"" |
character and the foreground and background colours and display style |
determined by the the ""fg"", ""bg"" and ""style"" parameters. For these, |
use the colorama package to set up the formatting. |
"""""" |
self._progress.add_progress(count, symbol, color, on_color, attrs)" |
424,"def format_status(self, width=None, |
label_width=None, |
progress_width=None, |
summary_width=None): |
""""""Generate the formatted status bar string."""""" |
if width is None: # pragma: no cover |
width = shutil.get_terminal_size()[0] |
if label_width is None: |
label_width = len(self.label) |
if summary_width is None: |
summary_width = self.summary_width() |
if progress_width is None: |
progress_width = width - label_width - summary_width - 2 |
if len(self.label) > label_width: |
# FIXME: This actually *will* break if we ever have fewer than |
# three characters assigned to format the label, but that would |
# be an extreme situation so I won't fix it just yet. |
label = self.label[:label_width - 3] + ""..."" |
else: |
label_format = ""{{label:{fill_char}<{width}}}"".format( |
width=label_width, |
fill_char=self.fill_char) |
label = label_format.format(label=self.label) |
summary_format = ""{{:>{width}}}"".format(width=summary_width) |
summary = summary_format.format(self._progress.format_summary()) |
progress = self._progress.format_progress(width=progress_width) |
return ""{label} {progress} {summary}"".format( |
label=label, |
progress=progress, |
summary=summary |
)" |
425,"def add_status_line(self, label): |
""""""Add a status bar line to the table. |
This function returns the status bar and it can be modified |
from this return value. |
"""""" |
status_line = StatusBar(label, |
self._sep_start, self._sep_end, |
self._fill_char) |
self._lines.append(status_line) |
return status_line" |
426,"def calculate_field_widths(self, width=None, |
min_label_width=10, |
min_progress_width=10): |
""""""Calculate how wide each field should be so we can align them. |
We always find room for the summaries since these are short and |
packed with information. If possible, we will also find room for |
labels, but if this would make the progress bar width shorter than |
the specified minium then we will shorten the labels, though never |
below the minium there. If this mean we have bars that are too wide |
for the terminal, then your terminal needs to be wider. |
"""""" |
if width is None: # pragma: no cover |
width = shutil.get_terminal_size()[0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.