Source code for gfinder.commands.geometry
"""GFINDER CLI `geometry` command."""
import click
from .docstring import set_docstring
from gfinder.geometry import GeometryFactory
@click.command(name='geometry')
@click.argument('class_name')
@click.option('--source-code/--no-source-code', help='Show source code for computing Geometry.', default='False')
def geometry_cmd(class_name, source_code):
"""Get information about a given geometry class.
"""
geometry(class_name, source_code=source_code)
[docs]@set_docstring(geometry_cmd, {'class_name': 'Geometry class name'})
def geometry(class_name, source_code=None):
geometry_class_dict = GeometryFactory().get_geometry_info(class_name)
if geometry_class_dict:
click.echo(geometry_class_dict['short_description'])
click.echo()
click.echo(f' Required parameters: {geometry_class_dict["required_parameters_sets"]}')
parent_class = geometry_class_dict['parent_class']
click.echo(f' Geometry class: {parent_class}')
if parent_class == 'Vector':
click.echo(f' Prefix: {geometry_class_dict["prefixes"]}')
click.echo(f' Units: {geometry_class_dict["units"]}')
if source_code:
click.echo()
click.echo(' Computation method:')
click.echo(geometry_class_dict["source"])