blob: d11ed0101f2b81b0d411e55e8d39ea161825691a [file] [log] [blame]
Fred Drake1189fa91998-12-22 18:24:13 +00001\section{\module{netrc} ---
Fred Drake39cddb71999-01-12 19:22:11 +00002 netrc file processing}
Fred Drake1189fa91998-12-22 18:24:13 +00003
4\declaremodule{standard}{netrc}
Fred Drake39cddb71999-01-12 19:22:11 +00005% Note the \protect needed for \file... ;-(
6\modulesynopsis{Loading of \protect\file{.netrc} files.}
Fred Drake1189fa91998-12-22 18:24:13 +00007\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}}
Thomas Woutersf8316632000-07-16 19:01:10 +000017A \class{netrc} instance or subclass instance encapsulates 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 Drake806764b1999-04-23 17:03:21 +000025
Fred Drake1189fa91998-12-22 18:24:13 +000026\subsection{netrc Objects \label{netrc-objects}}
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000027
28A \class{netrc} instance has the following methods:
29
Fred Drake1189fa91998-12-22 18:24:13 +000030\begin{methoddesc}{authenticators}{host}
31Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})}
32of authenticators for \var{host}. If the netrc file did not
33contain an entry for the given host, return the tuple associated with
34the `default' entry. If neither matching host nor default entry is
35available, return \code{None}.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000036\end{methoddesc}
37
Fred Drake806764b1999-04-23 17:03:21 +000038\begin{methoddesc}{__repr__}{}
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000039Dump the class data as a string in the format of a netrc file.
40(This discards comments and may reorder the entries.)
41\end{methoddesc}
42
43Instances of \class{netrc} have public instance variables:
44
45\begin{memberdesc}{hosts}
Fred Drake38e5d272000-04-03 20:13:55 +000046Dictionary mapping host names to \code{(\var{login}, \var{account},
Fred Drake1189fa91998-12-22 18:24:13 +000047\var{password})} tuples. The `default' entry, if any, is represented
48as a pseudo-host by that name.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000049\end{memberdesc}
50
51\begin{memberdesc}{macros}
52Dictionary mapping macro names to string lists.
53\end{memberdesc}