R/print_datapackage.R

Defines functions print.datapackage

#' @export
print.datapackage <- function(x, properties = NA, ...) {
  printdescription(x)
  cat("\n", c2("Location"), ": <", attr(x, "path"), ">", sep="")
  if (dp_nresources(x) > 0) {
    cat("\n\n", c2("Resources"), ":\n", sep = "")
    resources <- dp_resource_names(x)
    for (resource in resources) {
      print(dp_resource(x, resource), tiny = TRUE)
    }
  } else {
    cat(bd(c1("\n<NO RESOURCES>\n")))
  }
  attributes <- dp_properties(x)
  if (length(properties) == 1 && is.na(properties)) properties <- attributes
  properties  <- setdiff(properties, c("name", "title", "description", "resources"))
  toprint <- intersect(attributes, properties)
  if (length(toprint)) {
    tmp <- lapply(toprint, \(property) dp_property(x, property))
    names(tmp) <- toprint
    cat("\n", c2("Selected properties"), ":\n", sep = "")
    utils::str(tmp, max.level=1, give.attr=FALSE, no.list = TRUE, 
      comp.str="", indent.str="", give.head = FALSE)
  }
}

Try the datapackage package in your browser

Any scripts or data that you put into this service are public.

datapackage documentation built on June 8, 2025, 1:25 p.m.