freeports_analysis.conf_parse

Submodule containing all the utilities for validating and parsing the configuration

Functions

apply_config(config, config_location)

Update configuration and dict rappresenting from where the configuration is loaded using the configuration file and the environment variables

get_config_file(config, config_location)

Overwrite the configuration and the dict that rappresent from where the configuration is loaded on the CONFIG_FILE entry.

log_config(logger, config, config_location)

Log with debug priority the configuration provided

overwrite_with_config_file(config, ...)

Overwrite configuration provided and update the dictionary containing from where the configuration are loaded from accordingly, using the configuration file

overwrite_with_env_vars(config, config_location)

Overwrite configuration provided and update the dictionary containing from where the configuration are loaded from accordingly, using environment variables

validate_conf(config)

Function that validate the configuration provided

Classes

PossibleLocationConfig(*values)

Rappresent from where the options can come from

class freeports_analysis.conf_parse.PossibleLocationConfig(*values)

Rappresent from where the options can come from

freeports_analysis.conf_parse.apply_config(config: dict, config_location: dict) Tuple[dict, dict]

Update configuration and dict rappresenting from where the configuration is loaded using the configuration file and the environment variables

Parameters:
  • config (dict) – configuration to overwrite

  • config_location (dict) – location of configuration to update

Returns:

first dict is the new configuration, second is the updated location dict

Return type:

Tuple[dict,dict]

freeports_analysis.conf_parse.get_config_file(config: dict, config_location: dict) Tuple[dict, dict]

Overwrite the configuration and the dict that rappresent from where the configuration is loaded on the CONFIG_FILE entry. This has to be parsed before overwriting all the other options in order to set the correct configuration file to load

Parameters:
  • config (dict) – configuration to overwrite

  • config_location (dict) – location of configuration to update

Returns:

first dict is the new configuration, second is the updated location dict

Return type:

Tuple[dict,dict]

freeports_analysis.conf_parse.log_config(logger: Logger, config: dict, config_location: dict)

Log with debug priority the configuration provided

Parameters:

logger (log.Logger) – the logger that has to log

freeports_analysis.conf_parse.overwrite_with_config_file(config: dict, config_location: dict) Tuple[dict, dict]

Overwrite configuration provided and update the dictionary containing from where the configuration are loaded from accordingly, using the configuration file

Parameters:
  • config (dict) – configuration to overwrite

  • config_location (dict) – location of configuration to update

Returns:

first dict is the new configuration, second is the updated location dict

Return type:

Tuple[dict,dict]

freeports_analysis.conf_parse.overwrite_with_env_vars(config: dict, config_location: dict) Tuple[dict, dict]

Overwrite configuration provided and update the dictionary containing from where the configuration are loaded from accordingly, using environment variables

Parameters:
  • config (dict) – configuration to overwrite

  • config_location (dict) – location of configuration to update

Returns:

first dict is the new configuration, second is the updated location dict

Return type:

Tuple[dict,dict]

freeports_analysis.conf_parse.validate_conf(config: dict)

Function that validate the configuration provided

Parameters:

config (dict) – configuration to validate

Raises:
  • ValueError – verbosity must be in [0:5]

  • ValueError – at least one location for input file (from url or local filesystem) should be specified

  • ValueError – invalid out path

  • ValueError – invalid batch file path

  • ValueError – if in BATCH MODE out path has to be directory or .tar.gz archive