blob: 47b704b89609fac8c529c1487d383851ec5e9891 [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 Drake806764b1999-04-23 17:03:21 +000027
Fred Drake1189fa91998-12-22 18:24:13 +000028\subsection{netrc Objects \label{netrc-objects}}
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000029
30A \class{netrc} instance has the following methods:
31
Fred Drake1189fa91998-12-22 18:24:13 +000032\begin{methoddesc}{authenticators}{host}
33Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})}
34of authenticators for \var{host}. If the netrc file did not
35contain an entry for the given host, return the tuple associated with
36the `default' entry. If neither matching host nor default entry is
37available, return \code{None}.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000038\end{methoddesc}
39
Fred Drake806764b1999-04-23 17:03:21 +000040\begin{methoddesc}{__repr__}{}
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000041Dump the class data as a string in the format of a netrc file.
42(This discards comments and may reorder the entries.)
43\end{methoddesc}
44
45Instances of \class{netrc} have public instance variables:
46
47\begin{memberdesc}{hosts}
Fred Drake1189fa91998-12-22 18:24:13 +000048Dictionmary mapping host names to \code{(\var{login}, \var{account},
49\var{password})} tuples. The `default' entry, if any, is represented
50as a pseudo-host by that name.
Guido van Rossum5e97c9d1998-12-22 05:18:24 +000051\end{memberdesc}
52
53\begin{memberdesc}{macros}
54Dictionary mapping macro names to string lists.
55\end{memberdesc}