From eb7114d2754b6d813ef1273820d6c3107fd401e8 Mon Sep 17 00:00:00 2001 From: Carl Boettiger Date: Wed, 16 May 2018 13:13:36 -0700 Subject: [PATCH] roll back --- DESCRIPTION | 2 +- R/rdf_methods.R | 42 +++++++++++++----------------------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fc0f1c8..fe306c0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,7 +40,7 @@ Imports: redland, utils, stringi, readr -RoxygenNote: 6.0.1 +RoxygenNote: 6.0.1.9000 Roxygen: list(markdown = TRUE) Suggests: magrittr, covr, diff --git a/R/rdf_methods.R b/R/rdf_methods.R index 813867f..61a3441 100644 --- a/R/rdf_methods.R +++ b/R/rdf_methods.R @@ -32,21 +32,26 @@ length.rdf <- function(x){ redland::librdf_model_size(x$model@librdf_model) } +#' @export +print.rdf <- function(x, ...){ + cat(format.rdf(x, ...), sep = "\n") +} + + +#' @importFrom stringi stri_unescape_unicode #' @export # @param max_print maximum number of lines to print of rdf preview # @param max_preview if number of triples exceeds this, no preview # will be displayed, since preview method must currently serialize # entire triplestore. -print.rdf <- function(x, - format = getOption("rdf_print_format", "nquads"), - max_print = getOption("rdf_max_print", 10L), - max_preview = 1e5, - ...){ - +format.rdf <- function(x, + format = getOption("rdf_print_format", "nquads"), + max_print = getOption("rdf_max_print", 10L), + max_preview = 1e5, + ...){ n <- redland::librdf_model_size(x$model@librdf_model) header <- paste0("Total of ", n, " triples, stored in ", x$storage@type, "\n", - "-------------------------------\n") - + "-------------------------------\n") if(n < max_preview){ tmp <- tempfile() rdf_serialize(x, @@ -65,26 +70,5 @@ print.rdf <- function(x, } else { txt <- paste(header, "\n (preview supressed for performance)") } - - cat(txt, sep = "\n") -} - - -#' @importFrom stringi stri_unescape_unicode -#' @export -format.rdf <- function(x, - format = getOption("rdf_print_format", "nquads"), - ...){ - tmp <- tempfile() - rdf_serialize(x, - tmp, - format = format, - ...) - ## Fix encoding on nquads, ntriples - - txt <- paste0(header, stringi::stri_unescape_unicode( - paste(readLines(tmp, n = max_print), collapse = "\n")), - footer) - unlink(tmp) txt }