EDIorg / EMLassemblyline

R package for creating EML metadata
https://ediorg.github.io/EMLassemblyline/
MIT License
28 stars 13 forks source link

Fixes #110 #115

Closed kzollove closed 2 years ago

kzollove commented 2 years ago

Create physical.txt template with eml2eal()

Fixes https://github.com/EDIorg/EMLassemblyline/issues/110

In order to create EML from web-hosted entities, a mechanism is required for providing the physical information required to fully describe entities. This function does the reverse of that, creating the physical.txt template from an EML file. This function will be useful in an instance of updating a data package with large entities as the editor will not need to download the large entities.

kzollove commented 2 years ago

eml2make_eml() now adds entity URLs as arguments.

This does not yet go "full circle" because EAL still stops make_eml() if "files don't exist in the specified directory". This could be fixed in validate_file_names() (the function that returns the error message) by checking if files are in directory OR if they have provided URLs a/o physical.txt entries.

validate_file_names <- function(path, data.files){

  # Validate file presence ----------------------------------------------------

  # Index data.files in path
  files <- list.files(path)
  use_i <- data.files %in% files

  # Throw an error if any data.files are missing
  if (sum(use_i) != length(data.files)){
    stop(
      paste0(
        "\nThese files don't exist in the specified directory:\n", 
        paste(data.files[!use_i], collapse = "\n")
      ),
      call. = FALSE
    )
  }