Data Pre-Processor
The preprocessor looks for the DIRECT_INCLUDE= keyword in the input yaml and concatenates the associated file at this point in the input file. The result is written to the output file or standard out if - is specified. If the DIRECT_INCLUDE keyword has proceeding spaces these will be used to offset the lines which are being concatenated.
It is expected that the keyword in the input yaml file will take the following format:
DIRECT_INCLUDE=/path/to/file/to/be/included
Command line useage
yp-preprocessor input-file-name -o output-file-name [options]
Type yp-preprocessor --help
for a list of options. See Command Line Reference for
detail.
Python useage
from yamlprocessor.datapreprocessor import DataPreProcessor
preprocessor = DataPreProcessor()
preprocessor.add_replacements_map(keymap) # optional line
preprocessor.process_yaml(input_file, output_file)
Examples
Consider an input YAML file containing the following data:
DIRECT_INCLUDE=a.yaml
hello:
- location: *planet
targets:
- human
- cat
- dog
If a.yaml
contains:
_:
- &planet earth
Running the preprocessor on the input YAML file will yield the following output:
_:
- &planet earth
hello:
- location: *planet
targets:
- human
- cat
- dog
The preprocessor simply concatenates the contents of a.yaml at the correct place in the input yaml file. This file can then be passed to yp-data for parsing.