You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

44 lines
1.6 KiB

#!/usr/bin/env python3
# external
import click
from pprint import pprint
import utils.io
@click.group()
@click.pass_context
def reqbt(ctx):
'''Inspect the ReQBT dataset.\f'''
pass
# pretty label
def plabel(label, message, color):
click.echo(click.style(label+':', fg=color, bold=True) + ' %s' % message)
@reqbt.command()
@click.argument('filename')
@click.argument('name')
@click.pass_context
def find(ctx, filename, name):
data = utils.io.read_json(filename)
case = data.get(name, None)
try:
plabel('Name', case['name'], 'yellow')
plabel('Contributors', case['contributors'], 'yellow')
print(click.style('Deducible:', fg='yellow', bold=True),
'Yes' if case['deducible'] else 'No')
plabel('Quantity', case['quantity'], 'yellow')
for i, replicate in enumerate(case['replicates'], start=1):
click.echo(click.style('Replicate %d:', fg='yellow', bold=True) % i)
for key, value in replicate.items():
click.echo(' %-20s %s' % (click.style(key, fg='yellow', bold=True), ', '.join(value)))
for i, comparison in enumerate(case['comparisons'], start=1):
click.echo(click.style('Comparison %d:', fg='yellow', bold=True) % i)
click.echo(' %-20s %s' % (click.style('Name:', fg='yellow', bold=True), comparison.pop('name')))
for key, value in comparison.items():
click.echo(' %-20s %s' % (click.style(key, fg='yellow', bold=True), ', '.join(value)))
except TypeError:
click.echo("Case '%s' not found." % name)