@@ -140,6 +140,30 @@ \section{\module{urllib} ---
140140see the \function {urlencode()} function below.
141141\end {funcdesc }
142142
143+ \begin {datadesc }{_urlopener}
144+ The public functions \function {urlopen()} and
145+ \function {urlretrieve()} create an instance of the
146+ \class {FancyURLopener} class and use it to perform their requested
147+ actions. To override this functionality, programmers can create a
148+ subclass of \class {URLopener} or \class {FancyURLopener}, then assign
149+ that an instance of that class to the
150+ \code {urllib._urlopener} variable before calling the desired function.
151+ For example, applications may want to specify a different
152+ \mailheader {User-Agent} header than \class {URLopener} defines. This
153+ can be accomplished with the following code:
154+
155+ \begin {verbatim }
156+ import urllib
157+
158+ class AppURLopener(urllib.FancyURLopener):
159+ def __init__(self, *args):
160+ self.version = "App/1.7"
161+ urllib.FancyURLopener.__init__(self, *args)
162+
163+ urllib._urlopener = AppURLopener()
164+ \end {verbatim }
165+ \end {datadesc }
166+
143167\begin {funcdesc }{urlcleanup}{}
144168Clear the cache that may have been built up by previous calls to
145169\function {urlretrieve()}.
@@ -188,25 +212,18 @@ \section{\module{urllib} ---
188212tuples in the sequence.
189213\end {funcdesc }
190214
191- The public functions \function {urlopen()} and
192- \function {urlretrieve()} create an instance of the
193- \class {FancyURLopener} class and use it to perform their requested
194- actions. To override this functionality, programmers can create a
195- subclass of \class {URLopener} or \class {FancyURLopener}, then assign
196- that an instance of that class to the
197- \code {urllib._urlopener} variable before calling the desired function.
198- For example, applications may want to specify a different
199- \mailheader {User-Agent} header than \class {URLopener} defines. This
200- can be accomplished with the following code:
201-
202- \begin {verbatim }
203- class AppURLopener(urllib.FancyURLopener):
204- def __init__(self, *args):
205- self.version = "App/1.7"
206- urllib.FancyURLopener.__init__(self, *args)
215+ \begin {funcdesc }{pathname2url}{path}
216+ Convert the pathname \var {path} from the local syntax for a path to
217+ the form used in the path component of a URL. This does not produce a
218+ complete URL. The return value will already be quoted using the
219+ \function {quote()} function.
220+ \end {funcdesc }
207221
208- urllib._urlopener = AppURLopener()
209- \end {verbatim }
222+ \begin {funcdesc }{url2pathname}{path}
223+ Convert the path component \var {path} from an encoded URL to the local
224+ syntax for a path. This does not accept a complete URL. This
225+ function uses \function {unquote()} to decode \var {path}.
226+ \end {funcdesc }
210227
211228\begin {classdesc }{URLopener}{\optional {proxies\optional {, **x509}}}
212229Base class for opening and reading URLs. Unless you need to support
0 commit comments