Skip to contents

A thin wrapper that runs the static reference scans over each code file and returns the per-file read / write / source basenames repro_run_order() needs. Reads/writes come from code_file_refs() split by call type; sources from a scan for source() (R only — see lang below). All returned as lowercased basenames.

Usage

repro_file_io(code_text_list, lang = "R")

Arguments

code_text_list

a named list of code-text character vectors, one per file (names are the file_names), OR a named list of such lists when files are in more than one language (see lang)

lang

the language each element of code_text_list is in: either a single string applied to every file (default "R"), or a named character vector keyed by file_name for a mixed-language set. Python has no source()-equivalent for reusing a SIBLING analysis script by relative path (its code-reuse mechanism, import, names an installed module, not a local file run_order must sequence), so sources is always empty for a Python file; open(..., "w"/"a"/...) is classified as a write only when that same line's own mode argument says so (a bare open(x) defaults to Python's own read mode and is otherwise ambiguous between the two).

Value

a data frame with file_name and list-columns reads, writes, sources (each a character vector of basenames).

Examples

code <- list(clean.R = c("d <- read.csv('raw.csv')", "write.csv(d, 'clean.csv')"),
             analysis.R = c("source('clean.R')", "d <- read.csv('clean.csv')"))
io <- repro_file_io(code)
io$reads
#> [[1]]
#> [1] "raw.csv"
#> 
#> [[2]]
#> [1] "clean.csv"
#> 
io$writes
#> [[1]]
#> [1] "clean.csv"
#> 
#> [[2]]
#> character(0)
#>