Description
# ' Print a nested list
# '
# ' Prints a nested list in a way that looks nice
# '
# ' Useful for displaying the config of a PEP
# '
# ' @param lst list object to print
# ' @param level the indentation level
# '
# ' @examples
# ' projectConfig = system.file("extdata",
# ' "example_peps-master",
# ' "example_basic",
# ' "project_config.yaml",
# ' package = "pepr")
# ' p = Project(file = projectConfig)
# ' .printNestedList(config(p),level=2)
# ' @export
.printNestedList = function (lst , level = 0 ) {
if (! is.list(lst ))
stop(" The input is not a list, cannot be displayed." )
ns = names(lst )
for (i in seq_along(lst )) {
item = lst [[i ]]
itemName = ns [i ]
if (class(item ) == " list" ) {
if (! is.null(itemName ))
cat(rep(" " , level ), paste0(itemName , " :" ), fill = T )
.printNestedList(item , level + 2 )
} else {
if (is.null(item ))
item = " null"
cat(rep(" " , level ), paste0(itemName , " :" ), item , fill = T )
}
}
}
Reactions are currently unavailable
You can’t perform that action at this time.
pepr/R/utils.R
Lines 273 to 308 in c334466