Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 1 | % Module and documentation by Eric S. Raymond, 21 Dec 1998 |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 2 | |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 3 | \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 Drake | 292b9eb | 1998-12-22 18:40:50 +0000 | [diff] [blame^] | 11 | \versionadded{1.5.2} |
| 12 | |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 13 | The \class{netrc} class parses and encapsulates the netrc file format |
| 14 | used by the \UNIX{} \program{ftp} program and other FTP clients. |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 15 | |
| 16 | \begin{classdesc}{netrc}{\optional{file}} |
| 17 | A \class{netrc} instance or subclass instance enapsulates data from |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 18 | a netrc file. The initialization argument, if present, specifies the |
| 19 | file to parse. If no argument is given, the file \file{.netrc} in the |
| 20 | user's home directory will be read. Parse errors will raise |
| 21 | \exception{SyntaxError} with diagnostic information including the file |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 22 | name, line number, and terminating token. |
| 23 | \end{classdesc} |
| 24 | |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 25 | \subsection{netrc Objects \label{netrc-objects}} |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 26 | |
| 27 | A \class{netrc} instance has the following methods: |
| 28 | |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 29 | \begin{methoddesc}{authenticators}{host} |
| 30 | Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})} |
| 31 | of authenticators for \var{host}. If the netrc file did not |
| 32 | contain an entry for the given host, return the tuple associated with |
| 33 | the `default' entry. If neither matching host nor default entry is |
| 34 | available, return \code{None}. |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 35 | \end{methoddesc} |
| 36 | |
| 37 | \begin{methoddesc}{__repr__}{host} |
| 38 | Dump 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 | |
| 42 | Instances of \class{netrc} have public instance variables: |
| 43 | |
| 44 | \begin{memberdesc}{hosts} |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 45 | Dictionmary mapping host names to \code{(\var{login}, \var{account}, |
| 46 | \var{password})} tuples. The `default' entry, if any, is represented |
| 47 | as a pseudo-host by that name. |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 48 | \end{memberdesc} |
| 49 | |
| 50 | \begin{memberdesc}{macros} |
| 51 | Dictionary mapping macro names to string lists. |
| 52 | \end{memberdesc} |