Utility Functions

aws_vapor.utils.combine_user_data(files: List[Tuple[str, str]]) → str[source]

Make a multipart/* message from a file content.

Parameters:files – Paths to a file, a content of which will be used as ‘UserData’.
Returns:A multipart/* message attached a file content to.
aws_vapor.utils.get_property_from_config_file(section: str, key: str, default_value: str = None) → str[source]

Get a property value from a config file.

Parameters:
  • section – A name of a section.
  • key – A name of a property.
  • default_value – A value will be returned when a property is not defined.
Returns:

A property value corresponding to the key, which is property name, in the section, or default_value if the section is not defined or the key is not defined.

aws_vapor.utils.inject_params(lines: str, params: dict) → List[str][source]

Replace placeholders with parameters.

Parameters:
  • lines – A file content including placeholders ({{ … }}).
  • params – A mapping a name of placeholders to a value.
Returns:

A file content replaced placeholders with parameters.

aws_vapor.utils.load_from_config_file(config_directories: List[str] = None) → dict[source]

Load properties from a config file.

Parameters:config_directories – A path to config directory having ‘config’. If not specified, locating ‘config’ on GLOBAL_CONFIG_DIRECTORY and LOCAL_CONFIG_DIRECTORY.
Returns:A mapping of properties loaded from a config file.

example:

{
    'section': {
        'key1': 'value1',
        'key2': 'value2'
    }
}
aws_vapor.utils.open_output_file(relative_file_path: str) → io.TextIOBase[source]

Open an output file.

Parameters:relative_file_path – A path to an output file.
Returns:A file descriptor of an output file.
aws_vapor.utils.save_to_config_file(props: dict, save_on_global: bool = False)[source]

Save properties to a config file.

Parameters:
  • props – A mapping of properties.
  • save_on_global – A flag whether or not a new configuration will be saved globally.