Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_tabulate_formats():
"API: tabulate_formats is a list of strings" ""
supported = tabulate_formats
print("tabulate_formats = %r" % supported)
assert type(supported) is list
for fmt in supported:
assert type(fmt) is type("") # noqa
type=click.Choice(tabulate.tabulate_formats, case_sensitive=True),
help="The tablefmt option for python tabulate"
)
def main(tag, old_tag, report_type, links, tableformat):
"""Script to assist in generating the release changelog
This script will generate a simple or full diff of PRs that are merged
and present the data in a way that is easy to copy/paste into an email
or git tag.
"""
click.echo(f"Report Includes: {old_tag} -> {tag}")
gh = github.Github(docker.gh_token)
repo = gh.get_repo(REPO_NAME)
release = tag if tag == MASTER else repo.get_release(tag)
old_release = repo.get_release(old_tag)
def set_default_summary_fmt(value: str):
formats = tabulate.tabulate_formats + ['notebook', None]
if value not in formats:
raise ValueError(f"Summary does not support '{value}' format")
set_config(replace(config(), summary_fmt=value))
class _StreamTableShowing():
def __init__(self, streamtable, n):
self.streamtable = streamtable
self.n = n
def _repr_html_(self):
return self.streamtable.tabulate(n=self.n, tablefmt='html')
def __repr__(self):
return self.streamtable.tabulate(n=self.n, tablefmt='orgtbl')
StreamTable.tabulate.tablefmts = tabulate_formats
'stderr': Arg(
("--stderr",), "Redirect stderr to this file"),
'stdout': Arg(
("--stdout",), "Redirect stdout to this file"),
'log_file': Arg(
("-l", "--log-file"), "Location of the log file"),
'yes': Arg(
("-y", "--yes"),
"Do not prompt to confirm reset. Use with care!",
"store_true",
default=False),
'output': Arg(
("--output",), (
"Output table format. The specified value is passed to "
"the tabulate module (https://pypi.org/project/tabulate/). "
"Valid values are: ({})".format("|".join(tabulate_formats))
),
choices=tabulate_formats,
default="fancy_grid"),
# list_dag_runs
'no_backfill': Arg(
("--no_backfill",),
"filter all the backfill dagruns given the dag id", "store_true"),
'state': Arg(
("--state",),
"Only list the dag runs corresponding to the state"
),
# list_jobs
'limit': Arg(
("--limit",),
import math
import sys
import tabulate
import time
SELF_TIME = object()
TIME_FROM_SCOPE_START = object()
TIME_TO_SCOPE_END = object()
TIME_FROM_STACK_START = object()
TIME_TO_STACK_END = object()
TIME_FROM_LAST_IMPORTANT = object()
argp = argparse.ArgumentParser(
description='Process output of basic_prof builds')
argp.add_argument('--source', default='latency_trace.txt', type=str)
argp.add_argument('--fmt', choices=tabulate.tabulate_formats, default='simple')
argp.add_argument('--out', default='-', type=str)
args = argp.parse_args()
class LineItem(object):
def __init__(self, line, indent):
self.tag = line['tag']
self.indent = indent
self.start_time = line['t']
self.end_time = None
self.important = line['imp']
self.filename = line['file']
self.fileline = line['line']
self.times = {}
type=str, nargs="*",
help="directory to process (default to .)")
parser_analyze.add_argument("-e", "--energies", dest="get_energies",
action="store_true", help="Print energies")
parser_analyze.add_argument(
"-m", "--mag", dest="ion_list", type=str, nargs=1,
help="Print magmoms. ION LIST can be a range "
"(e.g., 1-2) or the string 'All' for all ions.")
parser_analyze.add_argument(
"-r", "--reanalyze", dest="reanalyze", action="store_true",
help="Force reanalysis. Typically, vasp_analyzer"
" will just reuse a vasp_analyzer_data.gz if "
"present. This forces the analyzer to reanalyze "
"the data.")
parser_analyze.add_argument(
"-f", "--format", dest="format", choices=tabulate_formats,
default="simple",
help="Format for table. Supports all options in tabulate package.")
parser_analyze.add_argument(
"-v", "--verbose", dest="verbose", action="store_true",
help="Verbose mode. Provides detailed output on progress.")
parser_analyze.add_argument(
"-d", "--detailed", dest="detailed", action="store_true",
help="Detailed, but slower mode. Parses vasprun.xml instead of "
"separate vasp outputs.")
parser_analyze.add_argument(
"-s", "--sort", dest="sort", choices=["energy_per_atom", "filename"],
default="energy_per_atom",
help="Sort criteria. Defaults to energy / atom.")
parser_analyze.set_defaults(func=analyze)
parser_query = subparsers.add_parser(
log.debug("backend:csv")
from csv import writer as tabber
from ._utils import StringIO
res = StringIO()
t = tabber(res, delimiter=',' if backend == 'csv' else '\t')
t.writerow(tab['columns'])
t.writerows(tab['data'])
t.writerow('')
t.writerow(list(tab['total'].keys()))
t.writerow(list(tab['total'].values()))
return res.getvalue().rstrip()
else: # pragma: nocover
raise RuntimeError("Should be unreachable")
else:
import tabulate as tabber
if backend not in tabber.tabulate_formats:
raise ValueError("Unknown backend:%s" % backend)
log.debug("backend:tabulate:" + backend)
COL_LENS = [max(len(Str(i[j])) for i in [COL_NAMES] + tab)
for j in range(len(COL_NAMES))]
COL_LENS[0] = min(
TERM_WIDTH - sum(COL_LENS[1:]) - len(COL_LENS) * 3 - 4,
COL_LENS[0])
tab = [[i[0][:COL_LENS[0]]] + i[1:] for i in tab]
return totals + tabber.tabulate(
tab, COL_NAMES, tablefmt=backend, floatfmt='.0f')
# from ._utils import tighten
default=False,
),
click.option(
"--arrays",
help="Output rows as arrays instead of objects",
is_flag=True,
default=False,
),
click.option("-c", "--csv", is_flag=True, help="Output CSV"),
click.option("--no-headers", is_flag=True, help="Omit CSV headers"),
click.option("-t", "--table", is_flag=True, help="Output as a table"),
click.option(
"-f",
"--fmt",
help="Table format - one of {}".format(
", ".join(tabulate.tabulate_formats)
),
default="simple",
),
click.option(
"--json-cols",
help="Detect JSON cols and output them as JSON, not escaped strings",
is_flag=True,
default=False,
),
)
):
fn = decorator(fn)
return fn
def _opt_callback_set_table_format(self, table_format, _):
if table_format not in tabulate.tabulate_formats:
self.print_error('TABLE_FORMAT must be one of: ' + ', '.join(tabulate.tabulate_formats))
return False
return True