read_netrc: Parsing netrc files

Description Usage Arguments Details Value Functions See Also Examples

Description

Parses an netrc file in different ways and return the credential specifications it contains.

Usage

1
2
3
4
read_netrc(x = netrc_path(), std = TRUE, line.number = FALSE,
  quiet = FALSE)

netrc_path()

Arguments

x

path or connection to an netrc file. Default is to look for file '.netrc' into the user's home directory.

std

indicates if the file should be parsed as a standard netrc file (TRUE), searched for R repository specifications (see Details) (FALSE), or if entries associated with R repositories should be skipped (NA).

line.number

logical that indicates if the starting and ending line number of each credential definition should also be returned.

quiet

logical that indicates if the function should return NULL if the file is not found, or throw an error.

Details

Entries in the netrc file can be associated to R repositories, which are looked up by install.pkgs via repos_url, by adding a comment line to a standard entry the following format:

1
2
3
4
5
6
7
8
9
# standard host credential entry
machine www.somehost.org
login tata
password toto

#repos @myRepo/a/b/c
machine www.myrepo.org
login user
password 1234

The first entry is standard and provide credentials for a named host.

The second entry starts with '#repos ', which indicates it is an entry for an R repository with shortcut key ('@myRepo') and an – optional – path to the actual repository on the host machine 'www.myrepo.org'.

Note that it is not mandatory to start the repository entry key with a '@', but it makes it clearer that the first part of the path is a key to be substituted rather than being part of the path.

Value

a character matrix with one row per credential and columns 'machine', 'login' and 'password' if std is TRUE or NA, and additional columns 'repos' and 'path' if std = FALSE.

Functions

See Also

Other auth: repos_auth, repos_url

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
try( read_netrc() )
read_netrc(quiet = TRUE)

## End(Not run)

# using toy example
f <- system.file('netrc', package = 'repotools')
if( interactive() ) file.show(f) else cat(readLines(f), sep = "\n")

# standard parsing
read_netrc(f)
read_netrc(f, line.number = TRUE)
# parse repo information
read_netrc(f, std = FALSE)
# skip repo entries
read_netrc(f, std = NA)
 

renozao/repotools documentation built on May 27, 2019, 5:53 a.m.