Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 1 | \section{\module{netrc} --- |
Fred Drake | 39cddb7 | 1999-01-12 19:22:11 +0000 | [diff] [blame] | 2 | netrc file processing} |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 3 | |
| 4 | \declaremodule{standard}{netrc} |
Fred Drake | 39cddb7 | 1999-01-12 19:22:11 +0000 | [diff] [blame] | 5 | % Note the \protect needed for \file... ;-( |
| 6 | \modulesynopsis{Loading of \protect\file{.netrc} files.} |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 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}} |
Thomas Wouters | f831663 | 2000-07-16 19:01:10 +0000 | [diff] [blame] | 17 | A \class{netrc} instance or subclass instance encapsulates 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 | 806764b | 1999-04-23 17:03:21 +0000 | [diff] [blame] | 25 | |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 26 | \subsection{netrc Objects \label{netrc-objects}} |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 27 | |
| 28 | A \class{netrc} instance has the following methods: |
| 29 | |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 30 | \begin{methoddesc}{authenticators}{host} |
| 31 | Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})} |
| 32 | of authenticators for \var{host}. If the netrc file did not |
| 33 | contain an entry for the given host, return the tuple associated with |
| 34 | the `default' entry. If neither matching host nor default entry is |
| 35 | available, return \code{None}. |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 36 | \end{methoddesc} |
| 37 | |
Fred Drake | 806764b | 1999-04-23 17:03:21 +0000 | [diff] [blame] | 38 | \begin{methoddesc}{__repr__}{} |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 39 | Dump 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 | |
| 43 | Instances of \class{netrc} have public instance variables: |
| 44 | |
| 45 | \begin{memberdesc}{hosts} |
Fred Drake | 38e5d27 | 2000-04-03 20:13:55 +0000 | [diff] [blame] | 46 | Dictionary mapping host names to \code{(\var{login}, \var{account}, |
Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 47 | \var{password})} tuples. The `default' entry, if any, is represented |
| 48 | as a pseudo-host by that name. |
Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 49 | \end{memberdesc} |
| 50 | |
| 51 | \begin{memberdesc}{macros} |
| 52 | Dictionary mapping macro names to string lists. |
| 53 | \end{memberdesc} |