blob: 58ba88ae24bec3bb4b22c359ac62935bfe8432c9 [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
11The \class{netrc} class parses and encapsulates the netrc file format
12used by the \UNIX{} \program{ftp} program and other FTP clients.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000013
14\begin{classdesc}{netrc}{\optional{file}}
15A \class{netrc} instance or subclass instance enapsulates data from
Fred Drake1189fa91998-12-22 18:24:13 +000016a netrc file. The initialization argument, if present, specifies the
17file to parse. If no argument is given, the file \file{.netrc} in the
18user's home directory will be read. Parse errors will raise
19\exception{SyntaxError} with diagnostic information including the file
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000020name, line number, and terminating token.
21\end{classdesc}
22
Fred Drake1189fa91998-12-22 18:24:13 +000023\subsection{netrc Objects \label{netrc-objects}}
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000024
25A \class{netrc} instance has the following methods:
26
Fred Drake1189fa91998-12-22 18:24:13 +000027\begin{methoddesc}{authenticators}{host}
28Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})}
29of authenticators for \var{host}. If the netrc file did not
30contain an entry for the given host, return the tuple associated with
31the `default' entry. If neither matching host nor default entry is
32available, return \code{None}.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000033\end{methoddesc}
34
35\begin{methoddesc}{__repr__}{host}
36Dump the class data as a string in the format of a netrc file.
37(This discards comments and may reorder the entries.)
38\end{methoddesc}
39
40Instances of \class{netrc} have public instance variables:
41
42\begin{memberdesc}{hosts}
Fred Drake1189fa91998-12-22 18:24:13 +000043Dictionmary mapping host names to \code{(\var{login}, \var{account},
44\var{password})} tuples. The `default' entry, if any, is represented
45as a pseudo-host by that name.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000046\end{memberdesc}
47
48\begin{memberdesc}{macros}
49Dictionary mapping macro names to string lists.
50\end{memberdesc}