blob: 479144a4f0c3aa6a3f0e67b763afd6fb92532277 [file] [log] [blame]
Guido van Rossum5e97c9d1998-12-22 05:18:24 +00001% Module and documentation by Eric S. Raymond, 21 Dec 1998
Guido van Rossum5e97c9d1998-12-22 05:18:24 +00002
Fred Drake1189fa91998-12-22 18:24:13 +00003\section{\module{netrc} ---
4 \file{.netrc} processing}
5
6\declaremodule{standard}{netrc}
7\moduleauthor{Eric S. Raymond}{esr@snark.thyrsus.com}
8\sectionauthor{Eric S. Raymond}{esr@snark.thyrsus.com}
9
10
Fred Drake292b9eb1998-12-22 18:40:50 +000011\versionadded{1.5.2}
12
Fred Drake1189fa91998-12-22 18:24:13 +000013The \class{netrc} class parses and encapsulates the netrc file format
14used by the \UNIX{} \program{ftp} program and other FTP clients.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000015
16\begin{classdesc}{netrc}{\optional{file}}
17A \class{netrc} instance or subclass instance enapsulates data from
Fred Drake1189fa91998-12-22 18:24:13 +000018a netrc file. The initialization argument, if present, specifies the
19file to parse. If no argument is given, the file \file{.netrc} in the
20user's home directory will be read. Parse errors will raise
21\exception{SyntaxError} with diagnostic information including the file
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000022name, line number, and terminating token.
23\end{classdesc}
24
Fred Drake1189fa91998-12-22 18:24:13 +000025\subsection{netrc Objects \label{netrc-objects}}
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000026
27A \class{netrc} instance has the following methods:
28
Fred Drake1189fa91998-12-22 18:24:13 +000029\begin{methoddesc}{authenticators}{host}
30Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})}
31of authenticators for \var{host}. If the netrc file did not
32contain an entry for the given host, return the tuple associated with
33the `default' entry. If neither matching host nor default entry is
34available, return \code{None}.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000035\end{methoddesc}
36
37\begin{methoddesc}{__repr__}{host}
38Dump the class data as a string in the format of a netrc file.
39(This discards comments and may reorder the entries.)
40\end{methoddesc}
41
42Instances of \class{netrc} have public instance variables:
43
44\begin{memberdesc}{hosts}
Fred Drake1189fa91998-12-22 18:24:13 +000045Dictionmary mapping host names to \code{(\var{login}, \var{account},
46\var{password})} tuples. The `default' entry, if any, is represented
47as a pseudo-host by that name.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000048\end{memberdesc}
49
50\begin{memberdesc}{macros}
51Dictionary mapping macro names to string lists.
52\end{memberdesc}