text stringlengths 0 828 |
|---|
if n == 0: |
fraction = 0 |
else: |
fraction = float(i)/n |
LEN_BAR = 25 |
num_plus = int(round(fraction*LEN_BAR)) |
s_plus = '+'*num_plus |
s_point = '.'*(LEN_BAR-num_plus) |
return '[{0!s}{1!s}] {2:d}/{3:d} - {4:.1f}%'.format(s_plus, s_point, i, n, fraction*100)" |
4570,"def _format_exe_info(py_len, exeinfo, format, indlevel): |
""""""Renders ExeInfo object in specified format"""""" |
ret = [] |
ind = "" "" * indlevel * NIND if format.startswith(""text"") else """" |
if format == ""markdown-list"": |
for si in exeinfo: |
ret.append("" - `{0!s}`: {1!s}"".format(si.filename, si.description)) |
if format == ""rest-list"": |
for si in exeinfo: |
ret.append(""* ``{0!s}``: {1!s}"".format(si.filename, si.description)) |
elif format == ""markdown-table"": |
mask = ""%-{0:d}s | %s"".format(py_len+2 ) |
ret.append(mask % (""Script name"", ""Purpose"")) |
ret.append(""-"" * (py_len + 3) + ""|"" + ""-"" * 10) |
for si in exeinfo: |
ret.append(mask % (""`{0!s}`"".format(si.filename), si.description)) |
elif format == ""text"": |
sbc = 1 # spaces between columns |
for si in exeinfo: |
ss = textwrap.wrap(si.description, 79 - py_len - sbc - indlevel*NIND) |
for i, s in enumerate(ss): |
if i == 0: |
filecolumn = si.filename + "" "" + (""."" * (py_len - len(si.filename))) |
else: |
filecolumn = "" "" * (py_len + 1) |
ret.append(""{}{}{}{}"".format(ind, filecolumn, "" ""*sbc, s)) |
ret.append("""") |
return ret" |
4571,"def format_exe_info(exeinfo, format=""text"", indlevel=0): |
"""""" |
Generates listing of all Python scripts available as command-line programs. |
Args: |
exeinfo -- list of ExeInfo objects |
format -- One of the options below: |
""text"" -- generates plain text for printing at the console |
""markdown-list"" -- generates MarkDown as list |
""markdown-table"" -- generates MarkDown as tables |
""rest-list"" -- generates reStructuredText as lists |
indents -- indentation level (""text"" format only) |
Returns: (list of strings, maximum filename size) |
list of strings -- can be joined with a ""\n"" |
maximum filename size |
"""""" |
py_len = max([len(si.filename) for si in exeinfo]) |
sisi_gra = [si for si in exeinfo if si.flag_gui == True] |
sisi_cmd = [si for si in exeinfo if si.flag_gui == False] |
sisi_none = [si for si in exeinfo if si.flag_gui is None] |
def get_title(x): |
return format_h4(x, format, indlevel*NIND) + [""""] |
ret = [] |
if len(sisi_gra) > 0: |
ret.extend(get_title(""Graphical applications"")) |
ret.extend(_format_exe_info(py_len, sisi_gra, format, indlevel + 1)) |
if len(sisi_cmd) > 0: |
ret.extend(get_title(""Command-line tools"", )) |
ret.extend(_format_exe_info(py_len, sisi_cmd, format, indlevel + 1)) |
if len(sisi_none) > 0: |
ret.extend(_format_exe_info(py_len, sisi_none, format, indlevel + 1)) |
return ret, py_len" |
4572,"def markdown_table(data, headers): |
"""""" |
Creates MarkDown table. Returns list of strings |
Arguments: |
data -- [(cell00, cell01, ...), (cell10, cell11, ...), ...] |
headers -- sequence of strings: (header0, header1, ...) |
"""""" |
maxx = [max([len(x) for x in column]) for column in zip(*data)] |
maxx = [max(ll) for ll in zip(maxx, [len(x) for x in headers])] |
mask = "" | "".join([""%-{0:d}s"".format(n) for n in maxx]) |
ret = [mask % headers] |
ret.append("" | "".join([""-""*n for n in maxx])) |
for line in data: |
ret.append(mask % line) |
return ret" |
4573,"def expand_multirow_data(data): |
"""""" |
Converts multirow cells to a list of lists and informs the number of lines of each row. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.