ncss-tech/SoilKnowledgeBase

Replace `pdftotext` with {pdftools}

brownag opened this issue · 0 comments

download_GDS() and download_KST() use a system call to pdftotext that appears to be generating warnings. Safe to assume that these parts are not being routinely updated (granted the PDFs are unchanged and are sourced from a standard location. Not sure what is causing "error in running command". Could potentially switch to {pdftools} for parsing--but will need to ensure that the same settings (-raw -nodiag) can be used and approximately the same TXT output generated

══ Warnings ════════════════════════════════════════════════════════════════════
── Warning ('test-refresh.R:17:3'): refresh (from source; pdftools required) ───
error in running command
Backtrace:
     ▆
  1. └─SoilKnowledgeBase::refresh(keep_pdf = TRUE) at test-refresh.R:17:2
  2.   ├─base::try(lapply(exportfn_sub, function(x) get(x)(...)))
  3.   │ └─base::tryCatch(...)
  4.   │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  5.   │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  6.   │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
  7.   └─base::lapply(exportfn_sub, function(x) get(x)(...))
  8.     └─SoilKnowledgeBase (local) FUN(X[[i]], ...)
  9.       └─get(x)(...)
 10.         └─SoilKnowledgeBase:::parse_GDS(...)
 11.           └─SoilKnowledgeBase:::download_GDS(...)
 12.             └─base::system(sprintf("pdftotext -raw -nodiag GDS.pdf"))
── Warning ('test-refresh.R:17:3'): refresh (from source; pdftools required) ───
'./inst/extdata/GDS' already exists
Backtrace:
     ▆
  1. └─SoilKnowledgeBase::refresh(keep_pdf = TRUE) at test-refresh.R:17:2
  2.   ├─base::try(lapply(exportfn_sub, function(x) get(x)(...)))
  3.   │ └─base::tryCatch(...)
  4.   │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  5.   │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  6.   │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
  7.   └─base::lapply(exportfn_sub, function(x) get(x)(...))
  8.     └─SoilKnowledgeBase (local) FUN(X[[i]], ...)
  9.       └─get(x)(...)
 10.         └─SoilKnowledgeBase:::parse_GDS(...)
 11.           └─SoilKnowledgeBase:::download_GDS(...)
 12.             └─base::dir.create(file.path(outpath, "GDS"), recursive = TRUE)
── Warning ('test-refresh.R:17:3'): refresh (from source; pdftools required) ───
error in running command
Backtrace:
     ▆
  1. └─SoilKnowledgeBase::refresh(keep_pdf = TRUE) at test-refresh.R:17:2
  2.   ├─base::try(lapply(exportfn_sub, function(x) get(x)(...)))
  3.   │ └─base::tryCatch(...)
  4.   │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  5.   │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  6.   │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
  7.   └─base::lapply(exportfn_sub, function(x) get(x)(...))
  8.     └─SoilKnowledgeBase (local) FUN(X[[i]], ...)
  9.       └─get(x)(...)
 10.         ├─base::try(...)
 11.         │ └─base::tryCatch(...)
 12.         │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 13.         │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 14.         │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 15.         └─SoilKnowledgeBase:::download_KST(...)
 16.           └─base::system(sprintf("pdftotext -raw -nodiag %s", fn))
── Warning ('test-refresh.R:17:3'): refresh (from source; pdftools required) ───
error in running command
Backtrace:
     ▆
  1. └─SoilKnowledgeBase::refresh(keep_pdf = TRUE) at test-refresh.R:17:2
  2.   ├─base::try(lapply(exportfn_sub, function(x) get(x)(...)))
  3.   │ └─base::tryCatch(...)
  4.   │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  5.   │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  6.   │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
  7.   └─base::lapply(exportfn_sub, function(x) get(x)(...))
  8.     └─SoilKnowledgeBase (local) FUN(X[[i]], ...)
  9.       └─get(x)(...)
 10.         ├─base::try(...)
 11.         │ └─base::tryCatch(...)
 12.         │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 13.         │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 14.         │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 15.         └─SoilKnowledgeBase:::download_KST(...)
 16.           └─base::system(sprintf("pdftotext -raw -nodiag %s", fn))