File: utils-format.R

package info (click to toggle)
r-cran-reticulate 1.41.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,088 kB
  • sloc: cpp: 5,154; python: 620; sh: 13; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (3)
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

sprintf <- function(fmt, ...) {
  
  dots <- eval(substitute(alist(...)))
  if (length(dots) == 0)
    return(fmt)
  
  base::sprintf(fmt, ...)
  
}

stopf <- function(fmt = "", ..., call. = FALSE) {
  stop(sprintf(fmt, ...), call. = call.)
}

warningf <- function(fmt = "", ..., call. = FALSE, immediate. = FALSE) {
  warning(sprintf(fmt, ...), call. = call., immediate. = immediate.)
}

messagef <- function(fmt = "", ..., appendLF = TRUE) {
  message(sprintf(fmt, ...), appendLF = appendLF)
}

printf <- function(fmt = "", ..., file = stdout()) {
  if (!is.null(fmt))
    cat(sprintf(fmt, ...), file = file, sep = "")
}

eprintf <- function(fmt = "", ..., file = stderr()) {
  if (!is.null(fmt))
    cat(sprintf(fmt, ...), file = file, sep = "")
}

writef <- function(fmt = "", ..., con = stdout()) {
  if (!is.null(fmt))
    writeLines(sprintf(fmt, ...), con = con)
}

ewritef <- function(fmt = "", ..., con = stderr()) {
  if (!is.null(fmt))
    writeLines(sprintf(fmt, ...), con = con)
}