Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printNestedList uses inconsistent indentation #43

Open
stolarczyk opened this issue Oct 30, 2020 · 0 comments
Open

printNestedList uses inconsistent indentation #43

stolarczyk opened this issue Oct 30, 2020 · 0 comments
Assignees
Labels

Comments

@stolarczyk
Copy link
Member

pepr/R/utils.R

Lines 273 to 308 in c334466

#' 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)
}
}
}

@stolarczyk stolarczyk added the bug label Oct 30, 2020
@stolarczyk stolarczyk self-assigned this Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant