Skip to content

Commit 879d131

Browse files
author
hornik
committed
Improve checking the ROR IDs.
git-svn-id: https://svn.r-project.org/R/trunk@87641 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent e8ba175 commit 879d131

File tree

2 files changed

+59
-7
lines changed

2 files changed

+59
-7
lines changed

src/library/tools/R/QC.R

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3901,6 +3901,17 @@ function(aar, strict = FALSE)
39013901
if(length(ids))
39023902
out$bad_authors_at_R_field_has_persons_with_dup_ORCID_identifiers <-
39033903
ids
3904+
ids <- .ROR_ID_from_person(aar)
3905+
pos <- which(!is.na(ids))
3906+
ids <- ids[pos]
3907+
pos <- pos[!.ROR_ID_is_valid(ids)]
3908+
if(length(pos))
3909+
out$bad_authors_at_R_field_has_persons_with_bad_ROR_identifiers <-
3910+
format(aar[pos])
3911+
ids <- ids[duplicated(ids)]
3912+
if(length(ids))
3913+
out$bad_authors_at_R_field_has_persons_with_dup_ROR_identifiers <-
3914+
ids
39043915
}
39053916
if(strict >= 3L) {
39063917
non_standard_roles <-
@@ -4007,7 +4018,15 @@ function(x)
40074018
if(length(bad <- x[["bad_authors_at_R_field_has_persons_with_dup_ORCID_identifiers"]])) {
40084019
c(gettext("Authors@R field gives persons with duplicated ORCID identifiers:"),
40094020
paste0(" ", bad))
4010-
}
4021+
},
4022+
if(length(bad <- x[["bad_authors_at_R_field_has_persons_with_bad_ROR_identifiers"]])) {
4023+
c(gettext("Authors@R field gives persons with invalid ROR identifiers:"),
4024+
paste0(" ", bad))
4025+
},
4026+
if(length(bad <- x[["bad_authors_at_R_field_has_persons_with_dup_ROR_identifiers"]])) {
4027+
c(gettext("Authors@R field gives persons with duplicated ROR identifiers:"),
4028+
paste0(" ", bad))
4029+
}
40114030
)
40124031
}
40134032

@@ -8203,6 +8222,20 @@ function(dir, localOnly = FALSE, pkgSize = NA)
82038222
if(length(pos))
82048223
out$bad_ORCID_iDs <- odb[pos, , drop = FALSE]
82058224
}
8225+
## Also check ROR IDs.
8226+
rdb <- .ROR_ID_db_from_package_sources(dir)
8227+
if(NROW(rdb)) {
8228+
## Only look at things that may be valid: the others are
8229+
## complained about elsewhere.
8230+
ind <- grepl(.ROR_ID_variants_regexp, rdb[, 1L])
8231+
rdb <- rdb[ind, , drop = FALSE]
8232+
}
8233+
if(NROW(rdb) && requireNamespace("curl", quietly = TRUE)) {
8234+
ids <- .ROR_ID_canonicalize(rdb[, 1L])
8235+
pos <- which(!.ROR_ID_is_alive(ids))
8236+
if(length(pos))
8237+
out$bad_ROR_IDs <- rdb[pos, , drop = FALSE]
8238+
}
82068239
}
82078240
}
82088241

@@ -8984,6 +9017,17 @@ function(x, ...)
89849017
collapse = ", "))),
89859018
collapse = "\n")
89869019
}),
9020+
fmt(if(length(y <- x$bad_ROR_IDs)) {
9021+
paste(c(if(NROW(y) > 1L)
9022+
"Found the following (possibly) invalid ROR IDs:"
9023+
else
9024+
"Found the following (possibly) invalid ROR IDs:",
9025+
sprintf(" ID: %s\t(from: %s)",
9026+
unlist(y[, 1L]),
9027+
vapply(y[, 2L], paste, "",
9028+
collapse = ", "))),
9029+
collapse = "\n")
9030+
}),
89879031
fmt(if(length(y <- x$encoding))
89889032
c(sprintf("Package encoding '%s' is deprecated.", y),
89899033
"Please change to UTF-8 for non-ASCII content.")),

src/library/tools/R/rortools.R

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,31 @@
4848

4949
### ** .ROR_ID_is_alive
5050

51-
## See <https://ror.readme.io/v2/docs/rest-api>
51+
.ROR_ID_is_alive <- function(x) {
52+
## For now use HEAD requests for the full ROR ID.
53+
## See <https://ror.readme.io/v2/docs/rest-api> for getting more
54+
## information.
55+
## Assume all given ids are canonical.
56+
urls <- sprintf("https://ror.org/%s", x)
57+
resp <- .curl_multi_run_worker(urls, nobody = TRUE)
58+
vapply(resp, .curl_response_status_code, 0L) == 200L
59+
}
5260

5361
### ** ROR_ID_from_person
5462

55-
ROR_ID_from_person <- function(x)
63+
.ROR_ID_from_person <- function(x)
5664
vapply(unclass(x),
5765
function(e) e$comment["ROR"] %||% NA_character_,
5866
"")
5967

60-
### ** ROR_ID_db_from_package_sources
68+
### ** .ROR_ID_db_from_package_sources
6169

62-
ROR_ID_db_from_package_sources <-
70+
.ROR_ID_db_from_package_sources <-
6371
function(dir, add = FALSE)
6472
{
65-
ids1 <- ROR_ID_from_person(.persons_from_metadata(dir))
73+
ids1 <- .ROR_ID_from_person(.persons_from_metadata(dir))
6674
ids1 <- ids1[!is.na(ids1)]
67-
ids2 <- ROR_ID_from_person(.persons_from_citation(dir))
75+
ids2 <- .ROR_ID_from_person(.persons_from_citation(dir))
6876
ids2 <- ids2[!is.na(ids2)]
6977
db <- data.frame(ID = c(character(), ids1, ids2),
7078
Parent = c(rep_len("DESCRIPTION",

0 commit comments

Comments
 (0)