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