Skip to content

Commit

Permalink
Replace use of conditionz with lifecycle for depreciation warnings
Browse files Browse the repository at this point in the history
resolves #908
  • Loading branch information
zachary-foster committed Mar 9, 2023
1 parent 05b6056 commit b996e9c
Show file tree
Hide file tree
Showing 51 changed files with 1,722 additions and 1,395 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Imports:
crayon,
cli,
phangorn,
conditionz
lifecycle
Suggests:
testthat,
vegan,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ importFrom(bold,bold_tax_name)
importFrom(cli,cat_line)
importFrom(cli,rule)
importFrom(cli,symbol)
importFrom(conditionz,ConditionKeeper)
importFrom(crayon,style)
importFrom(crul,AsyncVaried)
importFrom(crul,HttpClient)
Expand Down
7 changes: 5 additions & 2 deletions R/bold_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@
bold_search <- function(sci = NULL, id = NULL, fuzzy = FALSE,
dataTypes = 'basic', includeTree=FALSE, response=FALSE, name = NULL, ...) {

pchk(name, "sci")
if (!is.null(name)) sci <- name
if (!is.null(name)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "bold_search(name)", with = "bold_search(sci)")
sci <- name
}

stopifnot(!is.null(sci) | !is.null(id))
type <- if (is.null(sci)) "id" else "sci"
tmp <- switch(type,
Expand Down
7 changes: 5 additions & 2 deletions R/children.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ children <- function(...){
#' @rdname children
children.default <- function(sci_id, db = NULL, rows = NA, x = NULL, ...) {
nstop(db)
pchk(x, "sci_id")
if (!is.null(x)) sci_id <- x
if (!is.null(x)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "children(x)", with = "children(sci_id)")
sci_id <- x
}

results <- switch(
db,
itis = {
Expand Down
6 changes: 5 additions & 1 deletion R/classification.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ classification <- function(...){
classification.default <- function(sci_id, db = NULL, callopts = list(),
return_id = TRUE, rows = NA, x = NULL, ...) {
nstop(db)
pchk(x, "sci_id")
if (!is.null(x)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "classification(x)", with = "classification(sci_id)")
sci_id <- x
}

switch(
db,
itis = {
Expand Down
7 changes: 5 additions & 2 deletions R/comm2sci.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ comm2sci <- function(...) {
#' @rdname comm2sci
comm2sci.default <- function(com, db='ncbi', itisby='search',
simplify=TRUE, commnames = NULL, ...) {
pchk(commnames, "com")
if (!is.null(commnames)) com <- commnames
if (!is.null(commnames)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "comm2sci(commnames)", with = "comm2sci(com)")
com <- commnames
}

assert(com, "character")
assert(simplify, "logical")
temp <- lapply(com, sci_from_comm, db = db, simplify = simplify,
Expand Down
5 changes: 4 additions & 1 deletion R/downstream.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ downstream.default <- function(sci_id, db=NULL, downto=NULL,
intermediate=FALSE, rows=NA, x=NULL, ...) {
nstop(downto, "downto")
nstop(db)
pchk(x, "sci_id")
if (!is.null(x)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "downstream(x)", with = "downstream(sci_id)")
sci_id <- x
}
if (!is.null(x)) sci_id <- x
switch(
db,
Expand Down
6 changes: 5 additions & 1 deletion R/eol_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
eol_search <- function(sci, page=1, exact=NULL, filter_tid=NULL,
filter_heid=NULL, filter_by_string=NULL, cache_ttl=NULL, terms = NULL, ...) {

pchk(terms, "sci")
if (!is.null(terms)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "eol_search(terms)", with = "eol_search(sci)")
sci = terms
}

query <- gsub("\\s", "+", sci)
args <- tc(list(q = query, page = page, exact = exact,
filter_by_taxon_concept_id = filter_tid,
Expand Down
8 changes: 5 additions & 3 deletions R/gbif_downstream.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@
gbif_downstream <- function(id, downto, intermediate = FALSE, limit = 100,
start = NULL, key = NULL, ...) {

pchk(key, "id")
if (!is.null(key)) id <- key

if (!is.null(key)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "gbif_downstream(key)", with = "gbif_downstream(id)")
id <- key
}

should_be('intermediate', intermediate, 'logical')

downto <- tolower(downto)
Expand Down
11 changes: 9 additions & 2 deletions R/get_boldid.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ get_boldid <- function(sci, fuzzy = FALSE, dataTypes = 'basic',
assert(division, "character")
assert(parent, "character")
assert_rows(rows)
pchk(searchterm, "sci")
if (!is.null(searchterm)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_boldid(searchterm)", with = "get_boldid(sci)")
sci <- searchterm
}


if (inherits(sci, "character")) {
tstate <- taxon_state$new(class = "boldid", names = sci)
Expand Down Expand Up @@ -352,7 +356,10 @@ check_boldid <- function(x){
get_boldid_ <- function(sci, messages = TRUE, fuzzy = FALSE,
dataTypes='basic', includeTree=FALSE, rows = NA, searchterm = NULL, ...) {

pchk(searchterm, "sci")
if (!is.null(searchterm)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_boldid_(searchterm)", with = "get_boldid_(sci)")
sci <- searchterm
}
stats::setNames(lapply(sci, get_boldid_help, messages = messages,
fuzzy = fuzzy, dataTypes=dataTypes, includeTree=includeTree,
rows = rows, ...), sci)
Expand Down
12 changes: 10 additions & 2 deletions R/get_eolid.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ get_eolid <- function(sci_com, ask = TRUE, messages = TRUE,
assert(rank, "character")
assert(data_source, "character")
assert_rows(rows)
pchk(sciname, "sci_com")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_eolid(sciname)", with = "get_eolid(sci_com)")
sci_com <- sciname
}


if (inherits(sci_com, "character")) {
tstate <- taxon_state$new(class = "eolid", names = sci_com)
Expand Down Expand Up @@ -391,7 +395,11 @@ get_eol_pageid <- function(x) {
#' @rdname get_eolid
get_eolid_ <- function(sci_com, messages = TRUE, rows = NA, sciname = NULL,
...) {
pchk(sciname, "sci_com")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_eolid_(sciname)", with = "get_eolid_(sci_com)")
sci_com <- sciname
}

stats::setNames(lapply(sci_com, get_eolid_help, messages = messages,
rows = rows, ...), sci_com)
}
Expand Down
12 changes: 9 additions & 3 deletions R/get_gbifid.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ get_gbifid <- function(sci, ask = TRUE, messages = TRUE, rows = NA,
assert(rank, "character")
assert(method, "character")
assert_rows(rows)
pchk(sciname, "sci")

if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_gbifid(sciname)", with = "get_gbifid(sci)")
sci <- sciname
}

if (inherits(sci, "character")) {
tstate <- taxon_state$new(class = "gbifid", names = sci)
items <- sci
Expand Down Expand Up @@ -323,7 +326,10 @@ check_gbifid <- function(x){
get_gbifid_ <- function(sci, messages = TRUE, rows = NA, method = "backbone",
sciname = NULL) {

pchk(sciname, "sci")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_gbifid_(sciname)", with = "get_gbifid_(sci)")
sci <- sciname
}
stats::setNames(lapply(sci, get_gbifd_help, messages = messages,
rows = rows, method = method), sci)
}
Expand Down
6 changes: 5 additions & 1 deletion R/get_iucn.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ get_iucn <- function(sci, messages = TRUE, key = NULL, x = NULL, ...) {

assert(sci, c("character", "taxon_state"))
assert(messages, "logical")
pchk(x, "sci")
if (!is.null(x)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_iucn(x)", with = "get_iucn(sci)")
sci <- x
}


if (inherits(sci, "character")) {
tstate <- taxon_state$new(class = "iucn", names = sci)
Expand Down
11 changes: 9 additions & 2 deletions R/get_natservid.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ get_natservid <- function(sci_com, searchtype = "scientific", ask = TRUE,
assert(ask, "logical")
assert(messages, "logical")
assert_rows(rows)
pchk(query, "sci_com")
if (!is.null(commnames)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_natservid(query)", with = "get_natservid(sci_com)")
sci_com <- query
}


if (inherits(sci_com, "character")) {
tstate <- taxon_state$new(class = "natservid", names = sci_com)
Expand Down Expand Up @@ -266,7 +270,10 @@ check_natservid <- function(x){
get_natservid_ <- function(sci_com, searchtype = "scientific", messages = TRUE,
rows = NA, query = NULL, ...) {

pchk(query, "sci_com")
if (!is.null(query)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_natservid_(query)", with = "get_natservid_(sci_com)")
sci_com <- query
}
stats::setNames(
lapply(sci_com, get_natservid_help, searchtype = searchtype,
messages = messages, rows = rows, ...),
Expand Down
12 changes: 9 additions & 3 deletions R/get_nbnid.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ get_nbnid <- function(sci_com, ask = TRUE, messages = TRUE, rec_only = FALSE,
assert(rank, "character")
assert(messages, "logical")
assert_rows(rows)
pchk(name, "sci_com")

if (!is.null(name)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_nbnid(name)", with = "get_nbnid(sci_com)")
sci_com <- name
}

if (inherits(sci_com, "character")) {
tstate <- taxon_state$new(class = "nbnid", names = sci_com)
items <- sci_com
Expand Down Expand Up @@ -283,7 +286,10 @@ check_nbnid <- function(x){
#' @rdname get_nbnid
get_nbnid_ <- function(sci_com, messages = TRUE, rec_only = FALSE, rank = NULL,
rows = NA, name = NULL, ...) {
pchk(name, "sci_com")
if (!is.null(name)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_nbnid_(name)", with = "get_nbnid_(sci_com)")
sci_com <- name
}
stats::setNames(lapply(sci_com, get_nbnid_help, messages = messages,
rec_only = rec_only, rank = rank, rows = rows, ...), sci_com)
}
Expand Down
13 changes: 10 additions & 3 deletions R/get_pow.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ get_pow <- function(sci_com, accepted = FALSE, ask = TRUE, messages = TRUE,
assert(family_filter, "character")
assert(rank_filter, "character")
assert_rows(rows)
pchk(x, "sci_com")

if (!is.null(x)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_pow(x)", with = "get_pow(sci_com)")
sci_com <- x
}

if (inherits(sci_com, "character")) {
tstate <- taxon_state$new(class = "pow", names = sci_com)
items <- sci_com
Expand Down Expand Up @@ -286,7 +289,11 @@ check_pow <- function(x){
#' @export
#' @rdname get_pow
get_pow_ <- function(sci_com, messages = TRUE, rows = NA, x = NULL, ...) {
pchk(x, "sci_com")
if (!is.null(x)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_pow_(x)", with = "get_pow_(sci_com)")
sci_com <- x
}

stats::setNames(lapply(sci_com, get_pow_help, messages = messages,
rows = rows, ...), sci_com)
}
Expand Down
11 changes: 9 additions & 2 deletions R/get_tolid.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ get_tolid <- function(sci, ask = TRUE, messages = TRUE, rows = NA,
assert(sci, c("character", "taxon_state"))
assert(ask, "logical")
assert(messages, "logical")
pchk(sciname, "sci")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_tolid(sciname)", with = "get_tolid(sci)")
sci <- sciname
}

if (!all(is.na(rows))) {
assert(rows, c("numeric", "integer"))
stopifnot(rows > 0)
Expand Down Expand Up @@ -254,7 +258,10 @@ check_tolid <- function(x){
#' @export
#' @rdname get_tolid
get_tolid_ <- function(sci, messages = TRUE, rows = NA, sciname = NULL) {
pchk(sciname, "sci")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_tolid_(sciname)", with = "get_tolid_(sci)")
sci <- sciname
}
stats::setNames(
lapply(sci, get_tolid_help, messages = messages, rows = rows),
sci
Expand Down
12 changes: 9 additions & 3 deletions R/get_tpsid.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ get_tpsid <- function(sci, ask = TRUE, messages = TRUE, key = NULL,

assert(sci, c("character", "taxon_state"))
assert(ask, "logical")
assert(messages, "logical")
assert(family, "character")
assert(rank, "character")
assert_rows(rows)
pchk(sciname, "sci")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_tpsid(sciname)", with = "get_tpsid(sci)")
sci <- sciname
}


if (inherits(sci, "character")) {
tstate <- taxon_state$new(class = "tpsid", names = sci)
Expand Down Expand Up @@ -283,7 +286,10 @@ check_tpsid <- function(x){
get_tpsid_ <- function(sci, messages = TRUE, key = NULL, rows = NA,
sciname = NULL, ...) {

pchk(sciname, "sci")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_tpsid_(sciname)", with = "get_tpsid_(sci)")
sci <- sciname
}
stats::setNames(lapply(sci, get_tpsid_help, messages = messages, key=key,
rows = rows, ...), sci)
}
Expand Down
12 changes: 10 additions & 2 deletions R/get_tsn.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ get_tsn <- function(sci_com, searchtype = "scientific", accepted = FALSE,
assert(searchtype, "character")
assert(accepted, "logical")
assert_rows(rows)
pchk(searchterm, "sci_com")
if (!is.null(searchterm)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_tsn(searchterm)", with = "get_tsn(sci_com)")
sci_com <- searchterm
}


if (inherits(sci_com, "character")) {
tstate <- taxon_state$new(class = "tsn", names = sci_com)
Expand Down Expand Up @@ -269,7 +273,11 @@ check_tsn <- function(x){
#' @rdname get_tsn
get_tsn_ <- function(sci_com, messages = TRUE, searchtype = "scientific",
accepted = TRUE, rows = NA, searchterm = NULL, ...) {
pchk(searchterm, "sci_com")
if (!is.null(searchterm)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_tsn_(searchterm)", with = "get_tsn_(sci_com)")
sci_com <- searchterm
}

stats::setNames(
lapply(sci_com, get_tsn_help, messages = messages,
searchtype = searchtype, accepted = accepted, rows = rows, ...),
Expand Down
12 changes: 10 additions & 2 deletions R/get_uid.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ get_uid <- function(sci_com, ask = TRUE, messages = TRUE, rows = NA,
assert(rank_filter, "character")
assert_rows(rows)
key <- getkey(key, service = "entrez")
pchk(sciname, "sci_com")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_uid(sciname)", with = "get_uid(sci_com)")
sci_com <- sciname
}


if (inherits(sci_com, "character")) {
tstate <- taxon_state$new(class = "uid", names = sci_com)
Expand Down Expand Up @@ -406,7 +410,11 @@ get_uid_ <- function(sci_com, messages = TRUE, rows = NA, key = NULL,
sciname = NULL, ...) {

key <- getkey(key, "ENTREZ_KEY")
pchk(sciname, "sci_com")
if (!is.null(sciname)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_uid_(sciname)", with = "get_uid_(sci_com)")
sci_com <- sciname
}

stats::setNames(lapply(sci_com, get_uid_help, messages = messages,
rows = rows, key = key, ...), sci_com)
}
Expand Down
6 changes: 5 additions & 1 deletion R/get_wiki.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ get_wiki <- function(sci_com, wiki_site = "species", wiki = "en", ask = TRUE,
assert(wiki, "character")
assert(messages, "logical")
assert_rows(rows)
pchk(x, "sci_com")
if (!is.null(x)) {
lifecycle::deprecate_warn(when = "v0.9.97", what = "get_wiki(x)", with = "get_wiki(sci_com)")
sci_com <- x
}


if (inherits(sci_com, "character")) {
tstate <- taxon_state$new(class = "wiki", names = sci_com)
Expand Down
Loading

0 comments on commit b996e9c

Please sign in to comment.