API

pyimagediet.diet(filename, configuration)

Squeeze files if there is a pipeline defined for them or leave them be otherwise.

Parameters:
  • filename – filename of the file to process
  • configuration (dict) – configuration dict describing commands and pipelines
Returns:

has file changed

Return type:

bool

pyimagediet.parse_configuration(config)
Parse and fix configuration:
  • processed file should end up being same as input
  • pipelines should contain CLI commands to run
  • add missing sections
Parameters:config (dict) – raw configuration object
Returns:configuration ready for diet()
Return type:dict

Calls to diet can be sped up by parsing configuration dict first with parse_configuration and then using its return value as diet config object.

Helpers

pyimagediet.check_configuration(config)

Check if configuration object is not malformed.

Parameters:config (dict) – configuration
Returns:is configuration correct?
Return type:bool
pyimagediet.update_configuration(orig, new)

Update existing configuration with new values. Needed because dict.update is shallow and would overwrite nested dicts.

Function updates sections commands, parameters and pipelines and adds any new items listed in updates.

Parameters:
  • orig (dict) – configuration to update
  • new – new updated values
pyimagediet.read_yaml_configuration(filename)

Parse configuration in YAML format into a Python dict

Parameters:filename – filename of a file with configuration in YAML format
Returns:unprocessed configuration object
Return type:dict