def blue_info(self, msg, console=True):
     """
     Logs an info message
     :param msg:     (str)   message to be logged
     :param console  (bool)  If true, the message will also be displayed on console
     :return:
     """
     logging.info(msg)
     if console:
         self.write(colorize_text(True, False, 'INFO: ', COLOR_BLUE) + msg + '\n')
 def debug(self, msg, console=True):
     """
     Logs an info message
     :param msg:     (str)   message to be logged
     :param console  (bool)  If true, the message will also be displayed on console
     :return:
     """
     logging.debug(msg)
     if console and self.debug_flag:
         self.write(colorize_text(True, False, 'DEBUG: ') + msg + '\n')
 def warning(self, msg, console=True):
     """
     Logs an info message
     :param msg:     (str)   message to be logged
     :param console  (bool)  If true, the message will also be displayed on console
     :return:
     """
     logging.warning(msg)
     if console:
         self.write(colorize_text(True, False, 'WARNING: ', COLOR_YELLOW) + msg + '\n')
 def error(self, msg, console=True):
     """
     Logs an info message
     :param msg:     (str)   message to be logged
     :param console  (bool)  If true, the message will also be displayed on console
     :return:
     """
     logging.error(msg)
     if console:
         self.write(colorize_text(True, False, 'ERROR: ', COLOR_RED) + msg + '\n')
def parse():
    """
    Parses the arguments
    :return: Argparse instance containing the parameters
    """

    parser = argparse.ArgumentParser(description=colorize_text(True, True, 'Bonfire simulation / synthesis script',
                                                               package.COLOR_BLUE))

    parser._optionals.title = colorize_text(True, False, 'Optional arguments', package.COLOR_BLUE)

    exec_type = parser.add_argument_group(colorize_text(True, False, 'Execution type', package.COLOR_BLUE))

    exec_type_group = exec_type.add_mutually_exclusive_group(required=True)

    exec_type_group.add_argument('--simulate', '-s', type=str, required=False, metavar='DESIGN_CONFIG',
                                 help='Simulate the design stored in DESIGN_CONFIG')

    exec_type_group.add_argument('--synth', '-a', type=str, required=False, metavar='DESIGN_CONFIG',
                                 help='Synthesize design stored in DESIGN_CONFIG ' +
                                      colorize_text(True, False, 'NOT IMPLEMENTED YET', package.COLOR_RED))

    exec_type_group.add_argument('--fpga', '-f', type=str, required=False, metavar='DESIGN_CONFIG',
                                 help='Synthesize design stored in DESIGN_CONFIG for FPGA ' +
                                      colorize_text(True, False, 'NOT IMPLEMENTED YET', package.COLOR_RED))

    parser.add_argument('--debug', '-d', action='store_true', required=False,
                        help='Enable script debugging')

    # Display the --help message when no arguments are given
    if len(sys.argv[1:]) == 0:
        parser.print_help()
        # parser.print_usage() # for just the usage line
        parser.exit()

    # Parse the arguments
    args = parser.parse_args()

    if args.synth or args.fpga:
        raise ValueError('Requested functionality not yet implemented')

    return args