[Python-checkins] CVS: python/dist/src/Doc/lib libmimetypes.tex,1.9,1.10

Barry Warsaw bwarsaw@users.sourceforge.net
2001年10月25日 14:49:20 -0700


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv31010/Doc/lib
Modified Files:
	libmimetypes.tex 
Log Message:
Applying proposed patch for bug #474583, optional support for
non-standard but common types. Including Martin's suggestion to add
rejected non-standard types from patch #438790. Specifically,
guess_type(), guess_extension(): Both the functions and the methods
grow an optional "strict" flag, defaulting to true, which determines
whether to recognize non-standard, but commonly found types or not.
Also, I sorted, reformatted, and culled duplicates from the big
types_map dictionary. Note that there are a few non-equivalent
duplicates (e.g. .cdf and .xls) for which the first will just get
thrown away. I didn't remove those though.
Finally, use of the module as a script as grown the -l and -e options
to toggle strictness and to do guess_extension(), respectively.
Doc and unittest updates too.
Index: libmimetypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmimetypes.tex,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** libmimetypes.tex	2001年08月04日 00:48:49	1.9
--- libmimetypes.tex	2001年10月25日 21:49:18	1.10
***************
*** 9,16 ****
 \indexii{MIME}{content type}
 
! The \module{mimetypes} converts between a filename or URL and the MIME
! type associated with the filename extension. Conversions are provided 
! from filename to MIME type and from MIME type to filename extension;
! encodings are not supported for the later conversion.
 
 The module provides one class and a number of convenience functions.
--- 9,16 ----
 \indexii{MIME}{content type}
 
! The \module{mimetypes} module converts between a filename or URL and
! the MIME type associated with the filename extension. Conversions are
! provided from filename to MIME type and from MIME type to filename
! extension; encodings are not supported for the latter conversion.
 
 The module provides one class and a number of convenience functions.
***************
*** 24,43 ****
 
 
! \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})} where \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
! \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}
 Guess the extension for a file based on its MIME type, given by
 \var{type}.
--- 24,52 ----
 
 
! \begin{funcdesc}{guess_type}{filename\optional{, strict}}
 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})} where \var{type} is \code{None} if the type can't be
! guessed (missing 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}.
! 
! \var{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 sensitively, then case
! insensitively.
! 
! Optional \var{strict} is a flag specifying whether the list of known
! MIME types is limited to only the official types \ulink{registered
! with IANA}{http://www.isi.edu/in-notes/iana/assignments/media-types}
! are recognized. When \var{strict} is true (the default), only the
! IANA types are supported; when \var{strict} is false, some additional
! non-standard but commonly used MIME types are also recognized.
 \end{funcdesc}
 
! \begin{funcdesc}{guess_extension}{type\optional{, strict}}
 Guess the extension for a file based on its MIME type, given by
 \var{type}.
***************
*** 47,50 ****
--- 56,62 ----
 MIME type \var{type} by \function{guess_type()}. If no extension can
 be guessed for \var{type}, \code{None} is returned.
+ 
+ Optional \var{strict} has the same meaning as with the
+ \function{guess_type()} function.
 \end{funcdesc}
 
***************
*** 99,103 ****
--- 111,120 ----
 \end{datadesc}
 
+ \begin{datadesc}{common_types}
+ Dictionary mapping filename extensions to non-standard, but commonly
+ found MIME types.
+ \end{datadesc}
 
+ 
 The \class{MimeTypes} class may be useful for applications which may
 want more than one MIME-type database:
***************
*** 145,154 ****
 \end{datadesc}
 
! \begin{methoddesc}{guess_extension}{type}
 Similar to the \function{guess_extension()} function, using the
 tables stored as part of the object.
 \end{methoddesc}
 
! \begin{methoddesc}{guess_type}{url}
 Similar to the \function{guess_type()} function, using the tables
 stored as part of the object.
--- 162,177 ----
 \end{datadesc}
 
! \begin{datadesc}{common_types}
! Dictionary mapping filename extensions to non-standard, but commonly
! found MIME types. This is initially a copy of the global
! \code{common_types} defined in the module.
! \end{datadesc}
! 
! \begin{methoddesc}{guess_extension}{type\optional{, strict}}
 Similar to the \function{guess_extension()} function, using the
 tables stored as part of the object.
 \end{methoddesc}
 
! \begin{methoddesc}{guess_type}{url\optional{, strict}}
 Similar to the \function{guess_type()} function, using the tables
 stored as part of the object.

AltStyle によって変換されたページ (->オリジナル) /