Skip to content

Commit

Permalink
roll back
Browse files Browse the repository at this point in the history
  • Loading branch information
cboettig committed May 16, 2018
1 parent 793d33e commit eb7114d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
42 changes: 13 additions & 29 deletions R/rdf_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}

0 comments on commit eb7114d

Please sign in to comment.