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