This function reads a YAML file containing specifications, handles potential reading errors, and extracts specific information based on a provided path.
Usage
seasonder_readYAMLSpecs(file_path, path = rlang::zap())
Details
This function provides built-in error handling which aborts execution and logs detailed error messages in case of:
File not found.
Error in reading the YAML content.
The read YAML content is not a list.
No data found for the provided path in the YAML content.
Errors generated are of class "seasonder_read_yaml_file_error"
. For logging and aborting,
this function uses seasonder_logAndAbort
.
Examples
# Example: Read the CS header specifications (version V1) from the default specs file
specs_path <- seasonder_defaultSpecsFilePath("CS")
result <- seasonder_readYAMLSpecs(specs_path, c("header", "V1"))
str(result)
#> List of 3
#> $ nCsFileVersion:List of 3
#> ..$ type : chr "SInt16"
#> ..$ qc_fun : chr "qc_check_range"
#> ..$ qc_params:List of 3
#> .. ..$ min : int 1
#> .. ..$ max : int 32
#> .. ..$ expected_type: chr "integer"
#> $ nDateTime :List of 3
#> ..$ type : chr "UInt32"
#> ..$ qc_fun : chr "qc_check_unsigned"
#> ..$ qc_params:List of 1
#> .. ..$ expected_type: chr "numeric"
#> $ nV1Extent :List of 3
#> ..$ type : chr "SInt32"
#> ..$ qc_fun : chr "qc_check_type"
#> ..$ qc_params:List of 1
#> .. ..$ expected_type: chr "integer"