preprocess_file
preprocess_file(fname, dictionary, comment="!!", add_header=True, path_build=None)
Preprocesses a single template file, substituting pragma blocks and writing to path_build. Comment style is auto-detected from extension when comment="auto":
| Extension | Comment prefix |
|---|---|
.cpp, .hpp, .h |
"//" |
.f90, .f |
"!!" |
.py |
"#" |
.cmake |
"#" |
Parameters
- fname : str or Path
- Path to the template file.
- dictionary : dict[str, str]
- Mapping from pragma keys (without
PREPROCESS_prefix) to replacement strings. - comment : str, optional
- Comment prefix. Use
"auto"for extension-based detection. Default"!!". - add_header : bool, optional
- Prepend auto-generated header. Default
True. - path_build : str, Path, or None, optional
- Output directory. Defaults to current working directory.