Source code for gfinder.commands.scenario

"""GFINDER CLI `scenario` command."""

import click
from .docstring import set_docstring

from gfinder.config import Config
from gfinder.datastore import DataStore
import json


@click.command(name='scenario')
@click.argument('mission_scenario_id')
def scenario_cmd(mission_scenario_id):
    """Get information about a mission scenario.
    """
    scenario(mission_scenario_id=mission_scenario_id)


[docs]@set_docstring(scenario_cmd, {'mission_scenario_id': 'Mission scenario ID'}) def scenario(mission_scenario_id=None): # Init data store datastore = DataStore() # Get selected mission scenario if not mission_scenario_id: mission_scenario_id = Config().default_mission_scenario_id mission_scenario = datastore.getMissionScenario(mission_scenario_id) if mission_scenario: # TODO: To be implemented in MissionScenario.__str__() method. click.echo() click.echo(f' ID: {mission_scenario.id}') click.echo(f' Name: {mission_scenario.name}') # click.echo(f' description: {mission_scenario.description}') click.echo(f' SPICE metakernel: {mission_scenario.spice_metakernel}') click.echo(f' Event files keys: {list(mission_scenario.event_files_dict.keys())}') click.echo(' Event files:') for event_type in mission_scenario.event_files_dict: click.echo(f' - {event_type}: {mission_scenario.event_files_dict[event_type]}') click.echo() mission_scenario.loadKernels() click.echo('SPK kernels coverage:') kernels_cov = mission_scenario.getKernelsCoverage() if kernels_cov: click.echo(json.dumps(kernels_cov.get_dict(), indent=2)) else: click.echo(' None.') else: click.echo('Unknown mission scenario <{}>.'.format(mission_scenario_id))