source: vendor/python/2.5/Doc/lib/libnetrc.tex

Last change on this file was 3225, checked in by bird, 18 years ago

Python 2.5

File size: 2.6 KB
Line 
1\section{\module{netrc} ---
2 netrc file processing}
3
4\declaremodule{standard}{netrc}
5% Note the \protect needed for \file... ;-(
6\modulesynopsis{Loading of \protect\file{.netrc} files.}
7\moduleauthor{Eric S. Raymond}{esr@snark.thyrsus.com}
8\sectionauthor{Eric S. Raymond}{esr@snark.thyrsus.com}
9
10
11\versionadded{1.5.2}
12
13The \class{netrc} class parses and encapsulates the netrc file format
14used by the \UNIX{} \program{ftp} program and other FTP clients.
15
16\begin{classdesc}{netrc}{\optional{file}}
17A \class{netrc} instance or subclass instance encapsulates data from
18a netrc file. The initialization argument, if present, specifies the
19file to parse. If no argument is given, the file \file{.netrc} in the
20user's home directory will be read. Parse errors will raise
21\exception{NetrcParseError} with diagnostic information including the
22file name, line number, and terminating token.
23\end{classdesc}
24
25\begin{excdesc}{NetrcParseError}
26Exception raised by the \class{netrc} class when syntactical errors
27are encountered in source text. Instances of this exception provide
28three interesting attributes: \member{msg} is a textual explanation
29of the error, \member{filename} is the name of the source file, and
30\member{lineno} gives the line number on which the error was found.
31\end{excdesc}
32
33
34\subsection{netrc Objects \label{netrc-objects}}
35
36A \class{netrc} instance has the following methods:
37
38\begin{methoddesc}{authenticators}{host}
39Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})}
40of authenticators for \var{host}. If the netrc file did not
41contain an entry for the given host, return the tuple associated with
42the `default' entry. If neither matching host nor default entry is
43available, return \code{None}.
44\end{methoddesc}
45
46\begin{methoddesc}{__repr__}{}
47Dump the class data as a string in the format of a netrc file.
48(This discards comments and may reorder the entries.)
49\end{methoddesc}
50
51Instances of \class{netrc} have public instance variables:
52
53\begin{memberdesc}{hosts}
54Dictionary mapping host names to \code{(\var{login}, \var{account},
55\var{password})} tuples. The `default' entry, if any, is represented
56as a pseudo-host by that name.
57\end{memberdesc}
58
59\begin{memberdesc}{macros}
60Dictionary mapping macro names to string lists.
61\end{memberdesc}
62
63\note{Passwords are limited to a subset of the ASCII character set.
64Versions of this module prior to 2.3 were extremely limited. Starting with
652.3, all ASCII punctuation is allowed in passwords. However, note that
66whitespace and non-printable characters are not allowed in passwords. This
67is a limitation of the way the .netrc file is parsed and may be removed in
68the future.}
Note: See TracBrowser for help on using the repository browser.