Skip to content

Commit

Permalink
Capitalize comments
Browse files Browse the repository at this point in the history
  • Loading branch information
damianooldoni authored and peterdesmet committed Jan 16, 2024
1 parent 175fb52 commit 8b9f513
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions R/read_camtrap_dp.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
read_camtrap_dp <- function(file = NULL,
media = TRUE,
path = lifecycle::deprecated()) {
# check path (deprecated)
# Check path (deprecated)
warning_detail <- paste(
"Use argument `file` containing the path or URL to the `datapackage.json`",
"file. The use of parameter `path` with path to the local directory is ",
Expand All @@ -62,11 +62,11 @@ read_camtrap_dp <- function(file = NULL,
details = warning_detail
)
}
# define the right file value
# Define the right file value
if (lifecycle::is_present(path)) {
file <- file.path(path, "datapackage.json")
}
# file value is a valid path
# File value is a valid path
if (dir.exists(file)) {
file <- file.path(file, "datapackage.json")
}
Expand All @@ -79,13 +79,9 @@ read_camtrap_dp <- function(file = NULL,
# Read package (metadata)
package <- frictionless::read_package(file)

# Supported versions
supported_versions <- c("0.1.6", "1.0")

# Get package version
# Check Camtrap DP version is supported
version <- get_version(profile = package$profile)

# check version is supported
supported_versions <- c("0.1.6", "1.0")
assertthat::assert_that(
version %in% supported_versions,
msg = glue::glue(
Expand All @@ -94,9 +90,10 @@ read_camtrap_dp <- function(file = NULL,
)
)

# get resource names
# Get resource names
resource_names <- frictionless::resources(package)
#check needed resources are present

# Check needed resources are present
resources_to_read <- c("deployments", "media", "observations")
assertthat::assert_that(
all(resources_to_read %in% resource_names),
Expand All @@ -107,18 +104,18 @@ read_camtrap_dp <- function(file = NULL,
)
)

# read deployments
# Read deployments
deployments <- frictionless::read_resource(package, "deployments")
issues_deployments <- check_reading_issues(deployments, "deployments")
# read observations (needed to create sequenceID in media)
# Read observations (needed to create sequenceID in media)
observations <- frictionless::read_resource(package, "observations")
issues_observations <- check_reading_issues(observations, "observations")

if (version == "0.1.6"){
observations <- add_speed_radius_angle(observations)
}

# create first version datapackage with resources in data slot
# Create first version datapackage with resources in data slot
data <- list(
"deployments" = deployments,
"media" = NULL,
Expand All @@ -127,7 +124,7 @@ read_camtrap_dp <- function(file = NULL,

package$data <- data

# read media if needed
# Read media if needed
if (media) {
media_df <- frictionless::read_resource(package, "media")
issues_media <- check_reading_issues(media_df, "media")
Expand All @@ -139,12 +136,12 @@ read_camtrap_dp <- function(file = NULL,

package <- add_taxonomic_info(package)

# convert to 0.1.6
# Convert to 0.1.6
if (version == "1.0") {
package <- convert_to_0.1.6(package, version, media = media)
}

# order columns
# Order columns
package$data$deployments <- order_cols_deployments(package$data$deployments)
package$data$observations <- order_cols_observations(
package$data$observations
Expand Down

0 comments on commit 8b9f513

Please sign in to comment.