yaml_tools.yasort¶
Console script for sorting YAML lists.
Functions¶
|
Check filename extension, open and munge the contents, return data |
|
Set YAML formatting and sort keys from config, produce output data |
|
Handle file arguments and process them. Write new (sorted) files to |
|
Read/write YAML files with sorted list(s). |
Module Contents¶
- yaml_tools.yasort.get_input_yaml(filepath, prog_opts)[source]¶
Check filename extension, open and munge the contents, return data (where in this context we “munge” the curly braces to make it valid YAML).
- Parameters:
filepath – filename as Path obj
prog_opts (dict) – configuration options
- Return data_in:
file data
- Raises:
FileTypeError – if the input file is not yaml
- yaml_tools.yasort.sort_list_data(payload, prog_opts)[source]¶
Set YAML formatting and sort keys from config, produce output data from input dict-ish object.
- Parameters:
payload – Dict obj representing YAML input data
prog_opts (dict) – configuration options
- Return res:
yaml dump of sorted input
- yaml_tools.yasort.process_inputs(filepath, prog_opts, debug=False)[source]¶
Handle file arguments and process them. Write new (sorted) files to the ‘sorted-out/’ directory in the current working directory.
- Parameters:
filepath – filename as Path obj
prog_opts (dict) – configuration options
debug – enable extra processing info
- Return None:
- Handles FileTypeError:
if input file is not yml