blob: 66e6f4e20a2a7e31012c1454f75143a8e3b1b9a5 [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} ---
Fred Drake39cddb71999-01-12 19:22:11 +00004 netrc file processing}
Fred Drake1189fa91998-12-22 18:24:13 +00005
6\declaremodule{standard}{netrc}
Fred Drake39cddb71999-01-12 19:22:11 +00007% Note the \protect needed for \file... ;-(
8\modulesynopsis{Loading of \protect\file{.netrc} files.}
Fred Drake1189fa91998-12-22 18:24:13 +00009\moduleauthor{Eric S. Raymond}{esr@snark.thyrsus.com}
10\sectionauthor{Eric S. Raymond}{esr@snark.thyrsus.com}
11
12
Fred Drake292b9eb1998-12-22 18:40:50 +000013\versionadded{1.5.2}
14
Fred Drake1189fa91998-12-22 18:24:13 +000015The \class{netrc} class parses and encapsulates the netrc file format
16used by the \UNIX{} \program{ftp} program and other FTP clients.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000017
18\begin{classdesc}{netrc}{\optional{file}}
19A \class{netrc} instance or subclass instance enapsulates data from
Fred Drake1189fa91998-12-22 18:24:13 +000020a netrc file. The initialization argument, if present, specifies the
21file to parse. If no argument is given, the file \file{.netrc} in the
22user's home directory will be read. Parse errors will raise
23\exception{SyntaxError} with diagnostic information including the file
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000024name, line number, and terminating token.
25\end{classdesc}
26
Fred Drake1189fa91998-12-22 18:24:13 +000027\subsection{netrc Objects \label{netrc-objects}}
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000028
29A \class{netrc} instance has the following methods:
30
Fred Drake1189fa91998-12-22 18:24:13 +000031\begin{methoddesc}{authenticators}{host}
32Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})}
33of authenticators for \var{host}. If the netrc file did not
34contain an entry for the given host, return the tuple associated with
35the `default' entry. If neither matching host nor default entry is
36available, return \code{None}.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000037\end{methoddesc}
38
39\begin{methoddesc}{__repr__}{host}
40Dump the class data as a string in the format of a netrc file.
41(This discards comments and may reorder the entries.)
42\end{methoddesc}
43
44Instances of \class{netrc} have public instance variables:
45
46\begin{memberdesc}{hosts}
Fred Drake1189fa91998-12-22 18:24:13 +000047Dictionmary mapping host names to \code{(\var{login}, \var{account},
48\var{password})} tuples. The `default' entry, if any, is represented
49as a pseudo-host by that name.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000050\end{memberdesc}
51
52\begin{memberdesc}{macros}
53Dictionary mapping macro names to string lists.
54\end{memberdesc}