Example #1
0
def load_cmdl_into_dictionary(args_list):
    '''
    This function creates a dictionary based on the argument list provided

    @param arg_list: command line arguments
    @type arg_list: List
    '''
    logger.info("Starting command line arguments parsing process...")
    # This is the defaul configuration. Can be overriden by the configuration file and the command line
    input_cmdl_dict = {}
    # checking whether the input arguments match the specified RegEx.
    # If they do not match the regex/they are not "-h" or "--help", the process is stopped.
    for each_argument in args_list:
        # TODO: It is possible to define new default input commands such as --help
        if each_argument == "-h" or each_argument == "--help":
            how_to_use()
            exit(1)
        else:
            # Sanitize argument process
            try:
                input_cmdl_list = sanitize_input_cmdl_format(each_argument)
            except (invalidInputFormat, invalidInputOption):
                how_to_use()
                exit(1)
            # Update Dictionary
            input_cmdl_dict = merge_arg_into_dict(input_cmdl_dict, input_cmdl_list)

    logger.info('These are the parameters parsed from command line: {0} '.format(input_cmdl_dict))
    return input_cmdl_dict
Example #2
0
def load_config_file_into_dictionary(config_dict):
    '''
    This function creates a dictionary based on the argument list provided

    @param config_dict: Dictionary extracted from configuration file.
    @type config_dict: Dictionary
    '''
    logger.info("Starting config file parsing process...")
    # checking whether the input arguments match the specified RegEx.
    # If they do not match the regex/they are not "-h" or "--help", the process is stopped.
    # Creating aux list, which is necessary for dictionary_routes_parser
    cfg_file_dict = {}
    aux_lst = []
    config_file_input = dictionary_routes_parser(aux_lst, "", config_dict)
    for each_arg in config_file_input:
        try:
            cfg_file_list = sanitize_config_file_input(each_arg)
        except (invalidInputFormat, invalidInputOption):
            how_to_use()
            exit(1)
        cfg_file_dict = merge_arg_into_dict(cfg_file_dict, cfg_file_list)
    return cfg_file_dict