51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
|
import enum
|
||
|
|
||
|
import colorlog
|
||
|
import logging
|
||
|
import argparse
|
||
|
|
||
|
|
||
|
CONSOLE_LOGGER_NAME = 'FSFW Generator Logger'
|
||
|
LOGGER_INSTANCE = None
|
||
|
|
||
|
|
||
|
def get_console_logger():
|
||
|
global LOGGER_INSTANCE
|
||
|
if LOGGER_INSTANCE is None:
|
||
|
LOGGER_INSTANCE = init_console_logger()
|
||
|
return LOGGER_INSTANCE
|
||
|
|
||
|
|
||
|
def init_console_logger():
|
||
|
handler = colorlog.StreamHandler()
|
||
|
handler.setFormatter(colorlog.ColoredFormatter(
|
||
|
'%(log_color)s%(levelname)s: %(message)s'))
|
||
|
|
||
|
logger = colorlog.getLogger(CONSOLE_LOGGER_NAME)
|
||
|
logger.addHandler(handler)
|
||
|
logger.setLevel(logging.DEBUG)
|
||
|
return logger
|
||
|
|
||
|
|
||
|
class ParserTypes(enum.Enum):
|
||
|
EVENTS = 'events',
|
||
|
OBJECTS = 'objects',
|
||
|
RETVALS = 'returnvalues',
|
||
|
SUBSERVICES = 'subservices'
|
||
|
|
||
|
|
||
|
def init_printout():
|
||
|
global LOGGER_INSTANCE
|
||
|
LOGGER_INSTANCE = get_console_logger()
|
||
|
print('-- FSFW MOD Generator --')
|
||
|
|
||
|
|
||
|
def return_generic_args_parser() -> argparse.ArgumentParser:
|
||
|
parser = argparse.ArgumentParser('Arguments for FSFW MOD generation')
|
||
|
choices = ("events", "objects", "returnvalues", "subservices")
|
||
|
parser.add_argument(
|
||
|
'type', metavar='type', choices=choices,
|
||
|
help=f'Type of MOD data to generate. Choices: {choices}'
|
||
|
)
|
||
|
return parser
|