def get_configuration(): """ Get the configuration from command line and config files """ # This is the dict we will return configuration = {"global": {}, "logging": {}, "tables": {}} # Read the command line options cmd_line_options = command_line_parser.parse() # If a configuration file is specified, read that as well conf_file_options = None if "config" in cmd_line_options: conf_file_options = config_file_parser.parse(cmd_line_options["config"]) # Extract global config configuration["global"] = __get_global_options(cmd_line_options, conf_file_options) # Extract logging config configuration["logging"] = __get_logging_options(cmd_line_options, conf_file_options) # Extract table configuration # If the --table cmd line option is set, it indicates that only table # options from the command line should be used if "table_name" in cmd_line_options: configuration["tables"] = __get_cmd_table_options(cmd_line_options) else: configuration["tables"] = __get_config_table_options(conf_file_options) # Ensure some basic rules __check_gsi_rules(configuration) __check_logging_rules(configuration) __check_table_rules(configuration) return configuration
def get_configuration(): """ Get the configuration from command line and config files """ # This is the dict we will return configuration = { 'global': {}, 'logging': {}, 'tables': ordereddict() } # Read the command line options cmd_line_options = command_line_parser.parse() # If a configuration file is specified, read that as well conf_file_options = None if 'config' in cmd_line_options: conf_file_options = config_file_parser.parse( cmd_line_options['config']) # Extract global config configuration['global'] = __get_global_options( cmd_line_options, conf_file_options) # Extract logging config configuration['logging'] = __get_logging_options( cmd_line_options, conf_file_options) # Extract table configuration # If the --table cmd line option is set, it indicates that only table # options from the command line should be used if 'table_name' in cmd_line_options: configuration['tables'] = __get_cmd_table_options(cmd_line_options) elif 'dynamodb_table' in conf_file_options: configuration['tables'] = __get_dynamodb_config_options(conf_file_options) else: configuration['tables'] = __get_config_table_options(conf_file_options) # Ensure some basic rules __check_gsi_rules(configuration) __check_logging_rules(configuration) __check_table_rules(configuration) return configuration
def get_configuration(): """ Get the configuration from command line and config files """ # This is the dict we will return configuration = { 'global': {}, 'logging': {}, 'tables': {} } # Read the command line options cmd_line_options = command_line_parser.parse() # If a configuration file is specified, read that as well conf_file_options = None if 'config' in cmd_line_options: conf_file_options = config_file_parser.parse( cmd_line_options['config']) # Extract global config configuration['global'] = __get_global_options( cmd_line_options, conf_file_options) # Extract logging config configuration['logging'] = __get_logging_options( cmd_line_options, conf_file_options) # Extract table configuration # If the --table cmd line option is set, it indicates that only table # options from the command line should be used if 'table_name' in cmd_line_options: configuration['tables'] = __get_cmd_table_options(cmd_line_options) else: configuration['tables'] = __get_config_table_options(conf_file_options) # Ensure some basic rules __check_gsi_rules(configuration) __check_logging_rules(configuration) __check_table_rules(configuration) return configuration