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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
.dQuote <- function(x)
sprintf('"%s"', as.character(x))
.sQuote <- function(x)
sprintf("'%s'", as.character(x))
.msg <-
function(fmt, ..., width=getOption("width"))
## Use this helper to format all error / warning / message text
{
txt <- strwrap(sprintf(fmt, ...), width=width, exdent=2)
paste(txt, collapse="\n")
}
# use as BiocInstaller:::.opts$get() BiocInstaller:::.opts$set(TRUE)
.opts = local({
debug <- FALSE
list(get=function() debug, set=function(x) {
old <- debug
debug <<- x
old
})
})
.dbg <-
function(...)
{
if (.opts$get()) {
.msg(...)
}
}
.message <-
function(..., appendLF=TRUE)
{
message(.msg(...), appendLF=appendLF)
}
.stop <-
function(..., call.=FALSE)
{
stop(.msg(...), call.=call.)
}
.warning <-
function(..., call.=FALSE, immediate.=FALSE)
{
warning(.msg(...), call.=call., immediate.=immediate.)
}
.lowerRVersionString <-
function(version=getRversion())
{
if (0L == version$minor) {
major <- version$major - 1L
minor <- version$minor
} else {
major <- version$major
minor <- version$minor - 1L
}
paste(major, minor, sep=".")
}
# bootstrap() should take care of unloading BiocInstaller
# and reloading it.
.stepAside <-
function(biocBootstrapEnv, bootstrap)
{
environment(bootstrap) <- biocBootstrapEnv
biocBootstrapEnv[["bootstrap"]] <- bootstrap
attach(biocBootstrapEnv)
on.exit(eval(bootstrap(), biocBootstrapEnv))
}
|