forked from rstudio/shinyapps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.R
46 lines (38 loc) · 981 Bytes
/
utils.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
isStringParam <- function(param) {
is.character(param) && (length(param) == 1)
}
stringParamErrorMessage <- function(param) {
paste(param, "must be a single element character vector")
}
regexExtract <- function(re, input) {
match <- regexec(re, input)
matchLoc <- match[1][[1]]
if (length(matchLoc) > 1) {
matchLen <-attributes(matchLoc)$match.length
return (substr(input, matchLoc[2], matchLoc[2] + matchLen[2]-1))
}
else {
return (NULL)
}
}
displayStatus <- function(quiet) {
quiet <- quiet || httpDiagnosticsEnabled()
function (status) {
if (!quiet)
cat(status)
}
}
withStatus <- function(quiet) {
quiet <- quiet || httpDiagnosticsEnabled()
function(status, code) {
if (!quiet)
cat(status, "...", sep="")
force(code)
if (!quiet)
cat("DONE\n")
}
}
httpDiagnosticsEnabled <- function() {
return (getOption("shinyapps.http.trace", FALSE) ||
getOption("shinyapps.http.verbose", FALSE))
}