Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions R/list_ods_sheets.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.list_ods_sheets <- function(path, include_external_data = FALSE, .list_function) {
if (!file.exists(path)) {
stop(path, " does not exist", call. = FALSE)
}
return(.list_function(file = normalizePath(path, mustWork = FALSE), include_external_data = include_external_data))
}

#' Get information in an (F)ODS File
#'
#' `list_(f)ods_sheets` lists all sheets in an (f)ods file.
Expand All @@ -17,16 +24,15 @@
#' use \code{\link{read_ods}} to read the data
#' @export
list_ods_sheets <- function(path, include_external_data = FALSE) {
return(get_sheet_names_(file = normalizePath(path, mustWork = FALSE), include_external_data = include_external_data))
.list_ods_sheets(path, include_external_data = include_external_data, .list_function = get_sheet_names_)
}

#' @rdname list_ods_sheets
#' @export
list_fods_sheets <- function(path, include_external_data = FALSE) {
return(get_flat_sheet_names_(file = normalizePath(path, mustWork = FALSE), include_external_data = include_external_data))
.list_ods_sheets(path, include_external_data = include_external_data, .list_function = get_flat_sheet_names_)
}


#' @rdname list_ods_sheets
#' @export
ods_sheets <- function(path) {
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test_list_sheets.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ test_that("fix #163", {
writeLines("<ul><li>hello</li></ul>", rubbish_file)
expect_error(list_fods_sheets(rubbish_file)) ## won't stat in infinite loop
})

test_that("fix #169", {
expect_error(list_ods_sheets("this_surely_not_exists.ods"), "does not exist")
expect_error(list_fods_sheets("this_surely_not_exists.fods"), "does not exist")
})