Skip to content

Commit

Permalink
fix tier schema display in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
KaraMelih committed Dec 12, 2023
1 parent 882f8b1 commit bed91e4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions snews_pt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def message_schema(ctx, requested_tier):
displays everything
"""
from .messages import SNEWSHeartbeatMessage, SNEWSTimingTierMessage, SNEWSSignificanceTierMessage, \
SNEWSCoincidenceTierMessage, SNEWSRetractionMessage
SNEWSCoincidenceTierMessage, SNEWSRetractionMessage, SNEWSMessage

tier_data_pairs = {'CoincidenceTier': SNEWSCoincidenceTierMessage,
'SigTier': SNEWSSignificanceTierMessage,
'TimeTier': SNEWSTimingTierMessage,
Expand All @@ -125,11 +126,20 @@ def message_schema(ctx, requested_tier):
# check for aliases e.g. coinc = coincidence = CoinCideNceTier
tier = list(snews_pt_utils._check_aliases(requested_tier[0]))

basefields = SNEWSMessage.basefields
for t in tier:
TierMessage = tier_data_pairs[t]()
TierMessage.print_schema()


TierMessage = tier_data_pairs[t]
fields = TierMessage.fields
reqfields = TierMessage.reqfields
click.secho(f'Message schema for {t}', bg='white', fg='blue')
for f in fields:
if f in basefields:
click.secho(f'{f:<20s} : (SET AUTOMATICALLY)', fg='bright_red')
elif f in reqfields:
click.secho(f'{f:<20s} : (REQUIRED USER INPUT)', fg='bright_blue')
else:
click.secho(f'{f:<20s} : (USER INPUT)', fg='bright_cyan')
click.secho(f'{"**kwargs":<20s} : (GROUPED AS META)', fg='bright_green')

@main.command()
@click.option('--firedrill/--no-firedrill', default=True, show_default='True', help='Whether to use firedrill brokers or default ones')
Expand Down

0 comments on commit bed91e4

Please sign in to comment.