annotate Doc/liburlparse.tex @ 6719:faebc1940432 legacy-trunk

Understand -Xlinker option.
author Guido van Rossum <guido@python.org>
date Tue, 02 Dec 1997 20:38:11 +0000
parents 3468ea8645ca
children 10f2921a091e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2576
f47bc5554418 mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents: 2453
diff changeset
1 \section{Standard Module \sectcode{urlparse}}
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
2 \label{module-urlparse}
2449
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 \stmodindex{urlparse}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 \index{WWW}
2576
f47bc5554418 mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents: 2453
diff changeset
5 \index{World-Wide Web}
2449
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 \index{URL}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 \indexii{URL}{parsing}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 \indexii{relative}{URL}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
2453
cdd3a721b40e a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents: 2449
diff changeset
10 \renewcommand{\indexsubitem}{(in module urlparse)}
cdd3a721b40e a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents: 2449
diff changeset
11
2449
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 This module defines a standard interface to break URL strings up in
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 components (addessing scheme, network location, path etc.), to combine
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 the components back into a URL string, and to convert a ``relative
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 URL'' to an absolute URL given a ``base URL''.
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 The module has been designed to match the current Internet draft on
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 Relative Uniform Resource Locators (and discovered a bug in an earlier
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 draft!).
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 It defines the following functions:
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 \begin{funcdesc}{urlparse}{urlstring\optional{\,
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 default_scheme\optional{\, allow_fragments}}}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 Parse a URL into 6 components, returning a 6-tuple: (addressing
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 scheme, network location, path, parameters, query, fragment
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 identifier). This corresponds to the general structure of a URL:
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 \code{\var{scheme}://\var{netloc}/\var{path};\var{parameters}?\var{query}\#\var{fragment}}.
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 Each tuple item is a string, possibly empty.
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 The components are not broken up in smaller parts (e.g. the network
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 location is a single string), and \% escapes are not expanded.
2576
f47bc5554418 mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents: 2453
diff changeset
32 The delimiters as shown above are not part of the tuple items,
f47bc5554418 mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents: 2453
diff changeset
33 except for a leading slash in the \var{path} component, which is
f47bc5554418 mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents: 2453
diff changeset
34 retained if present.
2449
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 Example:
2647
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
37
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
38 \bcode\begin{verbatim}
2647
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
39 urlparse('http://www.cwi.nl:80/%7Eguido/Python.html')
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
40 \end{verbatim}\ecode
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
41 %
2449
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 yields the tuple
2647
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
43
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
44 \bcode\begin{verbatim}
2647
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
45 ('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '', '')
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
46 \end{verbatim}\ecode
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
47 %
2449
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 If the \var{default_scheme} argument is specified, it gives the
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 default addressing scheme, to be used only if the URL string does not
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 specify one. The default value for this argument is the empty string.
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 If the \var{allow_fragments} argument is zero, fragment identifiers
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 are not allowed, even if the URL's addressing scheme normally does
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 support them. The default value for this argument is \code{1}.
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 \end{funcdesc}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
56
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 \begin{funcdesc}{urlunparse}{tuple}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 Construct a URL string from a tuple as returned by \code{urlparse}.
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 This may result in a slightly different, but equivalent URL, if the
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 URL that was parsed originally had redundant delimiters, e.g. a ? with
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 an empty query (the draft states that these are equivalent).
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 \end{funcdesc}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
63
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 \begin{funcdesc}{urljoin}{base\, url\optional{\, allow_fragments}}
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 Construct a full (``absolute'') URL by combining a ``base URL''
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 (\var{base}) with a ``relative URL'' (\var{url}). Informally, this
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 uses components of the base URL, in particular the addressing scheme,
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 the network location and (part of) the path, to provide missing
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 components in the relative URL.
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
70
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 Example:
2647
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
72
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
73 \bcode\begin{verbatim}
2647
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
74 urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html')
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
75 \end{verbatim}\ecode
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
76 %
2647
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
77 yields the string
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
78
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
79 \bcode\begin{verbatim}
2647
9b7e6d9a528d typos, layout and other small things
Guido van Rossum <guido@python.org>
parents: 2576
diff changeset
80 'http://www.cwi.nl/%7Eguido/FAQ.html'
5818
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
81 \end{verbatim}\ecode
3468ea8645ca AMK's megapatch:
Guido van Rossum <guido@python.org>
parents: 2647
diff changeset
82 %
2449
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 The \var{allow_fragments} argument has the same meaning as for
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 \code{urlparse}.
8eeecd233d56 added WWW sections
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 \end{funcdesc}