Skip to content

Commit 342369e

Browse files
author
hornik
committed
Add .package_code_using_R_4.1_syntax().
Based on R-devel post by Ivan Krylov. git-svn-id: https://svn.r-project.org/R/trunk@87612 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 9854b13 commit 342369e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/library/tools/R/utils.R

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,48 @@ function(packages = NULL, FUN, ..., pattern = "*", verbose = TRUE,
21122112
out
21132113
}
21142114

2115+
### ** .package_code_using_R_4.1_syntax
2116+
2117+
.package_code_using_R_4.1_syntax <-
2118+
function(dir)
2119+
{
2120+
dir <- file_path_as_absolute(dir)
2121+
wrk <- function(f) {
2122+
x <- utils::getParseData(parse(f, keep.source = TRUE))
2123+
i <- x$token %in% c("PIPE", "'\\\\'")
2124+
utils::getParseText(x, x[i, "parent"])
2125+
}
2126+
one <- function(f)
2127+
tryCatch(wrk(file.path(dir, "R", f)), error = identity)
2128+
2129+
files <- list_files_with_type(file.path(dir, "R"), "code",
2130+
full.names = FALSE,
2131+
OS_subdirs = c("unix", "windows"))
2132+
out <- lapply(files, one)
2133+
names(out) <- files
2134+
Filter(length, out)
2135+
}
2136+
2137+
## ** .package_depends_on_R_at_least
2138+
2139+
.package_depends_on_R_at_least <-
2140+
function(dir, v)
2141+
{
2142+
.package_metadata_has_depends_on_R_at_least(.get_package_metadata(dir),
2143+
v)
2144+
}
2145+
2146+
### ** .package_metadata_has_depends_on_R_at_least
2147+
2148+
.package_metadata_has_depends_on_R_at_least <-
2149+
function(meta, v)
2150+
{
2151+
for(dep in .split_description(meta)$Rdepends2) {
2152+
if((dep$op == '>=') && (dep$version >= v)) return(TRUE)
2153+
}
2154+
FALSE
2155+
}
2156+
21152157
### ** .package_vignettes_via_call_to_R
21162158

21172159
.package_vignettes_via_call_to_R <-

0 commit comments

Comments
 (0)