From 22cfc2e41870543667cb4ad14c17ca933d5d8b6d Mon Sep 17 00:00:00 2001 From: "Rainer M. Krug" Date: Mon, 11 Dec 2023 15:37:09 +0100 Subject: [PATCH] Add comment to metadata json file starting with "_ --- R/metadata-validate.R | 6 +++++- inst/extdata/dc/schema-template.json | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/R/metadata-validate.R b/R/metadata-validate.R index 38378da2..302b4846 100644 --- a/R/metadata-validate.R +++ b/R/metadata-validate.R @@ -232,7 +232,7 @@ deposits_meta_from_file <- function (filename = NULL, } else { - meta <- readLines (filename) + meta <- readLines (filename, warn = FALSE) check <- jsonlite::validate (meta) if (!check) { stop ("json is not valid.") @@ -245,6 +245,10 @@ deposits_meta_from_file <- function (filename = NULL, num_resources_local <- length (meta$resources) meta <- meta$metadata } + + # remove comments defined names starting with "_" + meta <- meta[!grepl("^_", names(meta))] + meta <- meta [which (lapply (meta, length) > 0L)] attr (meta, "num_resources_local") <- num_resources_local diff --git a/inst/extdata/dc/schema-template.json b/inst/extdata/dc/schema-template.json index 33388f90..b471810c 100644 --- a/inst/extdata/dc/schema-template.json +++ b/inst/extdata/dc/schema-template.json @@ -1,5 +1,9 @@ { - "_note": "Fields like this starting with underscores are comments. Please delete this field, and all fields in this template except for those you wish to use for your deposit. This template may NOT be used in anything like this default form to construct a 'deposits' client. Many values require editing to comply with expected formats described throughout, such as dates or fields expected to accord with some fixed vocabulary, or modification from text descriptions to JSON objects. Please refer to the main 'dc/schema' file of the 'deposits' package for full details.", + "_note_1": "Fields like this starting with underscores are comments. They will be ignored when loading the metadata from the json file.", + "_note_2": "Please delete all fields in this template except for those you wish to use for your deposit. ", + "_note_3": "This template may NOT be used in anything like this default form to construct a 'deposits' client.", + "_note_4": "Many values require editing to comply with expected formats described throughout, such as dates or fields expected to accord with some fixed vocabulary, or modification from text descriptions to JSON objects.", + "_note_5": "Please refer to the main 'dc/schema' file of the 'deposits' package for full details.", "abstract": "Abstract text", "accessRights": "Access rights, which for Zenodo must be one of 'open', 'embargoed', 'restricted', or 'closed'.", "accrualMethod": "See https://www.dublincore.org/specifications/dublin-core/collection-description/accrual-method/; must be one of 'deposit', 'donation', 'purchase', 'loan', 'license', or 'item_creation'", @@ -80,4 +84,4 @@ "title": "A name given to the resource.", "type": "The nature or genre of the resource. Recommended practice is to use a controlled vocabulary such as the DCMI Type Vocabulary [DCMI-TYPE]. To describe the file format, physical medium, or dimensions of the resource, use the property Format.", "valid": "Date or date-time (often a range) of validity of a resource. Recommended practice is to describe the date, date/time, or period of time as recommended for the property Date, of which this is a subproperty." -} +} \ No newline at end of file