Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0ffa3eeb
Commit
0ffa3eeb
authored
Aug 03, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply the new \mailheader macro where appropriate, and fix a few small
markup inconsistencies.
parent
275c10ba
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
54 deletions
+57
-54
Doc/lib/libmailbox.tex
Doc/lib/libmailbox.tex
+2
-2
Doc/lib/libmimetools.tex
Doc/lib/libmimetools.tex
+15
-14
Doc/lib/libmimetypes.tex
Doc/lib/libmimetypes.tex
+13
-13
Doc/lib/librfc822.tex
Doc/lib/librfc822.tex
+17
-16
Doc/lib/liburllib.tex
Doc/lib/liburllib.tex
+10
-9
No files found.
Doc/lib/libmailbox.tex
View file @
0ffa3eeb
...
...
@@ -94,8 +94,8 @@ messages start with the EOOH line and end with a line containing only
\seetitle
[http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html]
{
Configuring
Netscape Mail on
\UNIX
: Why the Content-Length Format is
Bad
}{
A description of problems with relying on the
Content-Length header for messages stored in mailbox
files.
}
\mailheader
{
Content-Length
}
header for messages stored in
mailbox
files.
}
\end{seealso}
...
...
Doc/lib/libmimetools.tex
View file @
0ffa3eeb
...
...
@@ -68,8 +68,8 @@ The \class{Message} class defines the following methods in
addition to the
\class
{
rfc822.Message
}
methods:
\begin{methoddesc}
{
getplist
}{}
Return the parameter list of the
\
code
{
content-type
}
header. This is
a list of strings. For parameters of the form
Return the parameter list of the
\
mailheader
{
Content-Type
}
header.
This is
a list of strings. For parameters of the form
\samp
{
\var
{
key
}
=
\var
{
value
}}
,
\var
{
key
}
is converted to lower case but
\var
{
value
}
is not. For example, if the message contains the header
\samp
{
Content-type: text/html; spam=1; Spam=2; Spam
}
then
...
...
@@ -85,26 +85,27 @@ given \var{name}. If \var{value} is surrounded by quotes of the form
\end{methoddesc}
\begin{methoddesc}
{
getencoding
}{}
Return the encoding specified in the
\code
{
content-transfer-encoding
}
message header. If no such header exists, return
\code
{
'7bit'
}
. The
encoding is converted to lower case.
Return the encoding specified in the
\mailheader
{
Content-Transfer-Encoding
}
message header. If no such
header exists, return
\code
{
'7bit'
}
. The encoding is converted to
lower case.
\end{methoddesc}
\begin{methoddesc}
{
gettype
}{}
Return the message type (of the form
\samp
{
\var
{
type
}
/
\var
{
subtype
}}
)
as specified in the
\
code
{
content-type
}
header. If no such header
exists, return
\code
{
'text/plain'
}
. The type is converted to lower
case.
as specified in the
\
mailheader
{
Content-Type
}
header. If no such
header exists, return
\code
{
'text/plain'
}
. The type is converted to
lower
case.
\end{methoddesc}
\begin{methoddesc}
{
getmaintype
}{}
Return the main type as specified in the
\
code
{
content-type
}
header.
If no such header exists, return
\code
{
'text'
}
. The main type is
converted to lower case.
Return the main type as specified in the
\
mailheader
{
Content-Type
}
header. If no such header exists, return
\code
{
'text'
}
. The main
type is
converted to lower case.
\end{methoddesc}
\begin{methoddesc}
{
getsubtype
}{}
Return the subtype as specified in the
\
code
{
content-type
}
header. If
no such header exists, return
\code
{
'plain'
}
. The subtype is
converted to lower case.
Return the subtype as specified in the
\
mailheader
{
Content-Type
}
header. If no such header exists, return
\code
{
'plain'
}
. The subtype
is
converted to lower case.
\end{methoddesc}
Doc/lib/libmimetypes.tex
View file @
0ffa3eeb
...
...
@@ -20,17 +20,17 @@ module. If the module has not been initialized, they will call
\begin{funcdesc}
{
guess
_
type
}{
filename
}
Guess the type of a file based on its filename or URL, given by
\var
{
filename
}
.
The return value is a tuple
\code
{
(
\var
{
type
}
,
\var
{
encoding
}
)
}
wher
e
\var
{
type
}
is
\code
{
None
}
if the type can't be guessed (no or unknown
suffix) or a string of the form
\code
{
'
\var
{
type
}
/
\var
{
subtype
}
'
}
,
usable for a MIME
\code
{
content-type
}
header
\indexii
{
MIME
}{
headers
}
; and
encoding is
\code
{
None
}
for no encoding or the name of the program used
to encode (e.g.
\program
{
compress
}
or
\program
{
gzip
}
). The encoding
is suitable for use as a
\code
{
content-encoding
}
header,
\emph
{
not
}
as a
\code
{
content-transfer-encoding
}
header. The mappings
are table driven. Encoding suffixes are case sensitive; type suffixes
are
first tried case sensitive, then case insensitive.
\var
{
filename
}
.
The return value is a tuple
\code
{
(
\var
{
type
}
,
\var
{
encoding
}
)
}
where
\var
{
type
}
is
\code
{
None
}
if the type can't b
e
guessed (no or unknown suffix) or a string of the form
\code
{
'
\var
{
type
}
/
\var
{
subtype
}
'
}
, usable for a MIME
\mailheader
{
content-type
}
header
\indexii
{
MIME
}{
headers
}
; and encoding
is
\code
{
None
}
for no encoding or the name of the program used to
encode (e.g.
\program
{
compress
}
or
\program
{
gzip
}
). The encoding is
suitable for use as a
\mailheader
{
Content-Encoding
}
header,
\emph
{
not
}
as a
\mailheader
{
Content-Transfer-Encoding
}
header. The mappings are
table driven. Encoding suffixes are case sensitive; type suffixes are
first tried case sensitive, then case insensitive.
\end{funcdesc}
\begin{funcdesc}
{
guess
_
extension
}{
type
}
...
...
@@ -52,8 +52,8 @@ the behavior of the module.
Initialize the internal data structures. If given,
\var
{
files
}
must
be a sequence of file names which should be used to augment the
default type map. If omitted, the file names to use are taken from
\co
de
{
knownfiles
}
. Each file named in
\var
{
files
}
or
\co
de
{
knownfiles
}
takes precedence over those named before it.
\co
nstant
{
knownfiles
}
. Each file named in
\var
{
files
}
or
\co
nstant
{
knownfiles
}
takes precedence over those named before it.
Calling
\function
{
init()
}
repeatedly is allowed.
\end{funcdesc}
...
...
Doc/lib/librfc822.tex
View file @
0ffa3eeb
...
...
@@ -72,18 +72,19 @@ are stripped off.
\end{funcdesc}
\begin{funcdesc}
{
parseaddr
}{
address
}
Parse
\var
{
address
}
, which should be the value of some
address-containing
field such as
\code
{
To:
}
or
\code
{
Cc:
}
, into its constituent
``realname'' and ``email address'' parts. Returns a tuple of that
information, unless the parse fails, in which case a 2-tuple of
\code
{
(None, None)
}
is returned.
Parse
\var
{
address
}
, which should be the value of some
address-containing field such as
\mailheader
{
To
}
or
\mailheader
{
Cc
}
,
into its constituent ``realname'' and ``email address'' parts.
Returns a tuple of that information, unless the parse fails, in which
case a 2-tuple
\code
{
(None, None)
}
is returned.
\end{funcdesc}
\begin{funcdesc}
{
dump
_
address
_
pair
}{
pair
}
The inverse of
\method
{
parseaddr()
}
, this takes a 2-tuple of the form
\code
{
(realname, email
_
address)
}
and returns the string value suitable
for a
\code
{
To:
}
or
\code
{
Cc:
}
header. If the first element of
\var
{
pair
}
is false, then the second element is returned unmodified.
\code
{
(
\var
{
realname
}
,
\var
{
email
_
address
}
)
}
and returns the string
value suitable for a
\mailheader
{
To
}
or
\mailheader
{
Cc
}
header. If
the first element of
\var
{
pair
}
is false, then the second element is
returned unmodified.
\end{funcdesc}
\begin{funcdesc}
{
parsedate
}{
date
}
...
...
@@ -142,9 +143,9 @@ object is seekable.
\begin{methoddesc}
{
isheader
}{
line
}
Returns a line's canonicalized fieldname (the dictionary key that will
be used to index it) if the line is a legal
\rfc
{
2822
}
header; otherwise
returns
None (implying that parsing should stop here and the line b
e
pushed back on the input stream). It is sometimes useful to override
this method in a subclass.
returns
\code
{
None
}
(implying that parsing should stop here and th
e
line be pushed back on the input stream). It is sometimes useful to
override
this method in a subclass.
\end{methoddesc}
\begin{methoddesc}
{
islast
}{
line
}
...
...
@@ -200,8 +201,8 @@ header matching \var{name} exists, return \code{(None, None)};
otherwise both the full name and the address are (possibly empty)
strings.
Example: If
\var
{
m
}
's first
\
code
{
From
}
header contains the string
\code
{
'jack@cwi.nl (Jack Jansen)'
}
, then
Example: If
\var
{
m
}
's first
\
mailheader
{
From
}
header contains the
string
\code
{
'jack@cwi.nl (Jack Jansen)'
}
, then
\code
{
m.getaddr('From')
}
will yield the pair
\code
{
('Jack Jansen', 'jack@cwi.nl')
}
.
If the header contained
...
...
@@ -211,14 +212,14 @@ exact same result.
\begin{methoddesc}
{
getaddrlist
}{
name
}
This is similar to
\code
{
getaddr(
\var
{
list
}
)
}
, but parses a header
containing a list of email addresses (e.g.
\
a
\
code
{
To
}
header) and
containing a list of email addresses (e.g.
\
a
\
mailheader
{
To
}
header) and
returns a list of
\code
{
(
\var
{
full name
}
,
\var
{
email address
}
)
}
pairs
(even if there was only one address in the header). If there is no
header matching
\var
{
name
}
, return an empty list.
If multiple headers exist that match the named header (e.g. if there
are several
\
code
{
Cc
}
headers), all are parsed for addresses. Any
continuation lines the named headers contain are also parsed.
are several
\
mailheader
{
Cc
}
headers), all are parsed for addresses.
Any
continuation lines the named headers contain are also parsed.
\end{methoddesc}
\begin{methoddesc}
{
getdate
}{
name
}
...
...
Doc/lib/liburllib.tex
View file @
0ffa3eeb
...
...
@@ -168,8 +168,8 @@ subclass of \class{URLopener} or \class{FancyURLopener}, then assign
that an instance of that class to the
\code
{
urllib.
_
urlopener
}
variable before calling the desired function.
For example, applications may want to specify a different
\
code
{
user-agent
}
header than
\class
{
URLopener
}
defines. This can be
accomplished with the following code:
\
mailheader
{
User-Agent
}
header than
\class
{
URLopener
}
defines. This
can be
accomplished with the following code:
\begin{verbatim}
class AppURLopener(urllib.FancyURLopener):
...
...
@@ -187,9 +187,9 @@ opening objects using schemes other than \file{http:}, \file{ftp:},
\class
{
FancyURLopener
}
.
By default, the
\class
{
URLopener
}
class sends a
\
code
{
user-a
gent
}
header of
\samp
{
urllib/
\var
{
VVV
}}
, where
\
mailheader
{
User-A
gent
}
header of
\samp
{
urllib/
\var
{
VVV
}}
, where
\var
{
VVV
}
is the
\module
{
urllib
}
version number. Applications can
define their own
\
code
{
user-a
gent
}
header by subclassing
define their own
\
mailheader
{
User-A
gent
}
header by subclassing
\class
{
URLopener
}
or
\class
{
FancyURLopener
}
and setting the instance
attribute
\member
{
version
}
to an appropriate string value before the
\method
{
open()
}
method is called.
...
...
@@ -203,7 +203,7 @@ actually retrieve a resource at an \file{https:} URL.
\begin{classdesc}
{
FancyURLopener
}{
...
}
\class
{
FancyURLopener
}
subclasses
\class
{
URLopener
}
providing default
handling for the following HTTP response codes: 301, 302 or 401. For
301 and 302 response codes, the
\
code
{
l
ocation
}
header is used to
301 and 302 response codes, the
\
mailheader
{
L
ocation
}
header is used to
fetch the actual URL. For 401 response codes (authentication
required), basic HTTP authentication is performed. For 301 and 302 response
codes, recursion is bounded by the value of the
\var
{
maxtries
}
attribute,
...
...
@@ -257,10 +257,11 @@ is the raw data returned by the server. This may be binary data
(e.g. an image), plain text or (for example) HTML
\index
{
HTML
}
. The
HTTP
\indexii
{
HTTP
}{
protocol
}
protocol provides type information in the
reply header, which can be inspected by looking at the
\code
{
content-type
}
header. For the Gopher
\indexii
{
Gopher
}{
protocol
}
protocol, type information is encoded in the URL; there is currently
no easy way to extract it. If the returned data is HTML, you can use
the module
\refmodule
{
htmllib
}
\refstmodindex
{
htmllib
}
to parse it.
\mailheader
{
Content-Type
}
header. For the
Gopher
\indexii
{
Gopher
}{
protocol
}
protocol, type information is encoded
in the URL; there is currently no easy way to extract it. If the
returned data is HTML, you can use the module
\refmodule
{
htmllib
}
\refstmodindex
{
htmllib
}
to parse it.
\item
This module does not support the use of proxies which require
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment