| 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 | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 27 | \subsection{netrc Objects \label{netrc-objects}} | 
| Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 28 |  | 
 | 29 | A \class{netrc} instance has the following methods: | 
 | 30 |  | 
| Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 31 | \begin{methoddesc}{authenticators}{host} | 
 | 32 | Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})} | 
 | 33 | of authenticators for \var{host}.  If the netrc file did not | 
 | 34 | contain an entry for the given host, return the tuple associated with | 
 | 35 | the `default' entry.  If neither matching host nor default entry is | 
 | 36 | available, return \code{None}. | 
| Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 37 | \end{methoddesc} | 
 | 38 |  | 
 | 39 | \begin{methoddesc}{__repr__}{host} | 
 | 40 | Dump the class data as a string in the format of a netrc file. | 
 | 41 | (This discards comments and may reorder the entries.) | 
 | 42 | \end{methoddesc} | 
 | 43 |  | 
 | 44 | Instances of \class{netrc} have public instance variables: | 
 | 45 |  | 
 | 46 | \begin{memberdesc}{hosts} | 
| Fred Drake | 1189fa9 | 1998-12-22 18:24:13 +0000 | [diff] [blame] | 47 | Dictionmary mapping host names to \code{(\var{login}, \var{account}, | 
 | 48 | \var{password})} tuples.  The `default' entry, if any, is represented | 
 | 49 | as a pseudo-host by that name. | 
| Guido van Rossum | 5e97c9d | 1998-12-22 05:18:24 +0000 | [diff] [blame] | 50 | \end{memberdesc} | 
 | 51 |  | 
 | 52 | \begin{memberdesc}{macros} | 
 | 53 | Dictionary mapping macro names to string lists. | 
 | 54 | \end{memberdesc} |