1. Armin Rigo
  2. cpython-withatomic


Fred Drake  committed 4763a3d

Two new sections. Preliminary.

  • Participants
  • Parent commits 7f18f97
  • Branches legacy-trunk

Comments (0)

Files changed (3)

File Doc/lib/lib.tex

View file
 \input{libunix}			% UNIX Specific Services

File Doc/lib/librobotparser.tex

View file
+\section{\module{robotparser} --- 
+         Parser for \filenq{robots.txt}}
+\modulesynopsis{Accepts as input a list of lines or URL that refers to a
+                robots.txt file, parses the file, then builds a
+                set of rules from that list and answers questions
+                about fetchability of other URLs.}
+\sectionauthor{Skip Montanaro}{skip@mojam.com}
+\index{World-Wide Web}
+This module provides a single class, \class{RobotFileParser}, which answers
+questions about whether or not a particular user agent can fetch a URL on
+the web site that published the \file{robots.txt} file.  For more details on 
+the structure of \file{robots.txt} files, see
+This class provides a set of methods to read, parse and answer questions
+about a single \file{robots.txt} file.
+Sets the URL referring to a \file{robots.txt} file.
+Reads the \file{robots.txt} URL and feeds it to the parser.
+Parses the lines argument.
+\begin{methoddesc}{can_fetch}{useragent, url}
+Returns true if the \var{useragent} is allowed to fetch the \var{url}
+according to the rules contained in the parsed \file{robots.txt} file.
+Returns the time the \code{robots.txt} file was last fetched.  This is
+useful for long-running web spiders that need to check for new
+\code{robots.txt} files periodically.
+Sets the time the \code{robots.txt} file was last fetched to the current
+The following example demonstrates basic use of the RobotFileParser class.
+>>> import robotparser
+>>> rp = robotparser.RobotFileParser()
+>>> rp.set_url("http://www.musi-cal.com/robots.txt")
+>>> rp.read()
+>>> rp.can_fetch("*", "http://www.musi-cal.com/cgi-bin/search?city=San+Francisco")
+>>> rp.can_fetch("*", "http://www.musi-cal.com/")

File Doc/lib/libzipfile.tex

View file
+\section{\module{zipfile} ---
+         Work with ZIP archives}
+\modulesynopsis{Read and write ZIP-format archive files.}
+\moduleauthor{James C. Ahlstrom}{jim@interet.com}
+\sectionauthor{James C. Ahlstrom}{jim@interet.com}
+% LaTeX markup by Fred L. Drake, Jr. <fdrake@acm.org>
+The ZIP file format is a common archive and compression standard.
+This module provides tools to create, read, write, append, and list a
+ZIP file.
+The available attributes of this module are:
+  The error raised for bad ZIP files.
+  Level of printing, defaults to \code{1}.
+  The class for reading and writing ZIP files.  See
+  ``\citetitle{ZipFile Objects}'' (section \ref{zipfile-objects}) for
+  constructor details.
+  Returns true if \var{path} is a valid ZIP file based on its magic
+  number, otherwise returns false.  This module does not currently
+  handle ZIP files which have appended comments.
+  Return \code{(\var{year}, \var{month}, \var{day})} for a ZIP date
+  code.
+  Return \code{(\var{hour}, \var{minute}, \var{second})} for a ZIP
+  time code.
+\begin{funcdesc}{date2zip}{year, month, day}
+  Return a ZIP date code. 
+\begin{funcdesc}{time2zip}{hour, minute, second}
+  Return a ZIP time code.
+  The numeric constant (\code{0}) for an uncompressed archive member.
+  The numeric constant for the usual ZIP compression method.  This
+  requires the zlib module.  No other compression methods are
+  currently supported.
+  \seetext{XXX point to ZIP format definition}
+  \seetext{XXX point to Info-ZIP home page; mention WiZ}
+\subsection{ZipFile Objects \label{zipfile-objects}}
+\begin{classdesc}{ZipFile}{filename\optional{, mode\optional{, compression}}} 
+  Open a ZIP file named \var{filename}.  The \var{mode} parameter
+  should be \code{'r'} to read an existing file, \code{'w'} to
+  truncate and write a new file, or \code{'a'} to append to an
+  existing file.  For \var{mode} is \code{'a'} and \var{filename}
+  refers to an existing ZIP file, then additional files are added to
+  it.  If \var{filename} does not refer to a ZIP file, then a new ZIP
+  archive is appended to the file.  This is meant for adding a ZIP
+  archive to another file, such as \file{python.exe}.  Using
+cat myzip.zip >> python.exe
+  also works, and at least \program{WinZip} can read such files.
+  \var{compression} is the ZIP compression method to use when writing
+  the archive, and should be \constant{ZIP_STORED} or
+  \constant{ZIP_DEFLATED}; unrecognized values will cause
+  \exception{ValueError} to be raised.  The default is
+  \constant{ZIP_STORED}. 
+XXX explain the "extra" string for the ZIP format
+  A read-only dictionary whose keys are the names in the archive, and
+  whose values are tuples as follows:
+  \lineii{0}{File data seek offset}
+  \lineii{1}{ZIP file "extra" data as a string}
+  \lineii{2}{ZIP file bit flags}
+  \lineii{3}{ZIP file compression type}
+  \lineii{4}{File modification time in DOS format}
+  \lineii{5}{File modification date in DOS format}
+  \lineii{6}{The CRC-32 of the uncompressed data}
+  \lineii{7}{The compressed size of the file}
+  \lineii{8}{The uncompressed size of the file}
+The class ZipFile has these methods: 
+  Return a list of names in the archive.  Equivalent to
+  \code{\var{zipfile}.TOC.keys()}.
+  Print a table of contents for the archive to stdout. 
+  Return the bytes of the file in the archive.  The archive must be
+  open for read or append.
+\begin{methoddesc}{writestr}{bytes, arcname, year, month, day, hour,
+                             minute, second\optional{, extra}}
+  Write the string \var{bytes} and the other data to the archive, and
+  give the archive member the name \var{arcname}.  \var{extra} is the
+  ZIP extra data string.  The archive must be opened with mode
+  \code{'w'} or \code{'a'}.
+\begin{methoddesc}{write}{filename, arcname\optional{, extra}}
+  Write the file named \var{filename} to the archive, giving it the
+  archive name \var{arcname}.  \var{extra} is the ZIP extra data
+  string.  The archive must be open with mode \code{'w'} or
+  \code{'a'}.
+\begin{methoddesc}{writepy}{pathname\optional{, basename}}
+  Search for files \file{*.py} and add the corresponding file to the
+  archive.  The corresponding file is a \file{*.pyo} file if
+  available, else a \file{*.pyc} file, compiling if necessary.  If the
+  pathname is a file, the filename must end with \file{.py}, and just
+  the (corresponding \file{*.py[oc]}) file is added at the top level
+  (no path information).  If it is a directory, and the directory is
+  not a package directory, then all the files \file{*.py[oc]} are
+  added at the top level.  If the directory is a package directory,
+  then all \file{*.py[oc]} are added under the package name as a file
+  path, and if any subdirectories are package directories, all of
+  these are added recursively.  \var{basename} is intended for
+  internal use only.  The \method{writepy()} method makes archives
+  with file names like this:
+    string.pyc                                # Top level name 
+    test/__init__.pyc                         # Package directory 
+    test/testall.pyc                          # Module test.testall
+    test/bogus/__init__.pyc                   # Subpackage directory 
+    test/bogus/myfile.pyc                     # Submodule test.bogus.myfile
+  Close the archive file.  You must call \method{close()} before
+  exiting your program or essential records will not be written.