Source code for gfinder.commands.opportunity
"""GFINDER CLI `opportunity` command."""
import click
from .docstring import set_docstring
from gfinder.datastore import DataStore
@click.command(name='opportunity')
@click.argument('opportunity-id')
@click.option('--depth', type=click.INT, help='Depth of data (1:sequence, 2:observation, 3:measurement)', default=2)
def opportunity_cmd(opportunity_id, depth):
"""Get information about an opportunity.
"""
opportunity(opportunity_id, depth=depth)
[docs]@set_docstring(opportunity_cmd, {'opportunity_id': 'Opportunity ID'})
def opportunity(opportunity_id, depth=None):
# Init data store
datastore = DataStore()
# Retrieve opportunity_dict from data store if exists
opportunity_dict = datastore.getOpportunityDict(opportunity_id)
if not opportunity_dict:
click.echo()
click.echo('Unknown Opportunity ID:' + opportunity_id)
return None
opportunity = datastore.load_opportunity(opportunity_id)
if opportunity is None:
click.echo(f'Could not load {opportunity_id} opportunity data.')
return None
opportunity.summary(depth=depth)
return opportunity