Kaydet (Commit) 3bbd1157 authored tarafından Fred Drake's avatar Fred Drake

markup changes

üst e33aef7b
...@@ -12,7 +12,7 @@ Some facts and figures: ...@@ -12,7 +12,7 @@ Some facts and figures:
\begin{itemize} \begin{itemize}
\item reads and writes \module{gzip} and \module{bzip2} compressed archives. \item reads and writes \module{gzip} and \module{bzip2} compressed archives.
\item creates POSIX 1003.1-1990 compliant or GNU tar compatible archives. \item creates \POSIX{} 1003.1-1990 compliant or GNU tar compatible archives.
\item reads GNU tar extensions \emph{longname}, \emph{longlink} and \item reads GNU tar extensions \emph{longname}, \emph{longlink} and
\emph{sparse}. \emph{sparse}.
\item stores pathnames of unlimited length using GNU tar extensions. \item stores pathnames of unlimited length using GNU tar extensions.
...@@ -52,19 +52,19 @@ Some facts and figures: ...@@ -52,19 +52,19 @@ Some facts and figures:
a file object opened for \var{name}. a file object opened for \var{name}.
For special purposes, there is a second format for \var{mode}: For special purposes, there is a second format for \var{mode}:
\code{'filemode|[compression]'}. \code{open} will return a \class{TarFile} \code{'filemode|[compression]'}. \function{open()} will return a
object that processes its data as a stream of blocks. No random \class{TarFile} object that processes its data as a stream of
seeking will be done on the file. If given, \var{fileobj} may be any blocks. No random seeking will be done on the file. If given,
object that has a \code{read()} resp. \code{write()} method. \var{fileobj} may be any object that has a \method{read()} or
\var{bufsize} specifies the blocksize and defaults to \code{20 * 512} \method{write()} method (depending on the \var{mode}).
bytes. Use this variant in combination with e.g. \code{sys.stdin}, a socket \var{bufsize} specifies the blocksize and defaults to \code{20 *
file object or a tape device. 512} bytes. Use this variant in combination with
However, such a \class{TarFile} object is limited in that it does not allow e.g. \code{sys.stdin}, a socket file object or a tape device.
to be accessed randomly, see \citetitle{Examples} (section However, such a \class{TarFile} object is limited in that it does
\ref{tar-examples}). not allow to be accessed randomly, see ``Examples''
The currently possible modes: (section~\ref{tar-examples}). The currently possible modes:
\begin{tableii}{c|l}{code}{mode}{action} \begin{tableii}{c|l}{code}{Mode}{Action}
\lineii{'r|'}{Open a \emph{stream} of uncompressed tar blocks for reading.} \lineii{'r|'}{Open a \emph{stream} of uncompressed tar blocks for reading.}
\lineii{'r|gz'}{Open a gzip compressed \emph{stream} for reading.} \lineii{'r|gz'}{Open a gzip compressed \emph{stream} for reading.}
\lineii{'r|bz2'}{Open a bzip2 compressed \emph{stream} for reading.} \lineii{'r|bz2'}{Open a bzip2 compressed \emph{stream} for reading.}
...@@ -77,26 +77,25 @@ Some facts and figures: ...@@ -77,26 +77,25 @@ Some facts and figures:
\begin{classdesc*}{TarFile} \begin{classdesc*}{TarFile}
Class for reading and writing tar archives. Do not use this Class for reading and writing tar archives. Do not use this
class directly, better use \function{open()} instead. class directly, better use \function{open()} instead.
See \citetitle{TarFile Objects} (section \ref{tarfile-objects}). See ``TarFile Objects'' (section~\ref{tarfile-objects}).
\end{classdesc*} \end{classdesc*}
\begin{funcdesc}{is_tarfile}{name} \begin{funcdesc}{is_tarfile}{name}
Return \code{True} if \var{name} is a tar archive file, that the Return \constant{True} if \var{name} is a tar archive file, that
\module{tarfile} module can read. the \module{tarfile} module can read.
\end{funcdesc} \end{funcdesc}
\begin{classdesc}{TarFileCompat}{filename\optional{, mode\optional{, \begin{classdesc}{TarFileCompat}{filename\optional{, mode\optional{,
compression}}} compression}}}
Class for limited access to tar archives with a
Class for limited access to tar archives with a \code{zipfile}-like \refmodule{zipfile}-like interface. Please consult the
interface. Please consult the documentation of \code{zipfile} for more documentation of the \refmodule{zipfile} module for more details.
details. \var{compression} must be one of the following constants:
\code{compression} must be one of the following constants:
\begin{datadesc}{TAR_PLAIN} \begin{datadesc}{TAR_PLAIN}
Constant for an uncompressed tar archive. Constant for an uncompressed tar archive.
\end{datadesc} \end{datadesc}
\begin{datadesc}{TAR_GZIPPED} \begin{datadesc}{TAR_GZIPPED}
Constant for a \code{gzip} compressed tar archive. Constant for a \refmodule{gzip} compressed tar archive.
\end{datadesc} \end{datadesc}
\end{classdesc} \end{classdesc}
...@@ -125,7 +124,7 @@ Some facts and figures: ...@@ -125,7 +124,7 @@ Some facts and figures:
\end{excdesc} \end{excdesc}
\begin{seealso} \begin{seealso}
\seemodule{zipfile}{Documentation of the \code{zipfile} \seemodule{zipfile}{Documentation of the \refmodule{zipfile}
standard module.} standard module.}
\seetitle[http://www.gnu.org/manual/tar/html_chapter/tar_8.html\#SEC118] \seetitle[http://www.gnu.org/manual/tar/html_chapter/tar_8.html\#SEC118]
...@@ -162,7 +161,7 @@ tar archive several times. Each archive member is represented by a ...@@ -162,7 +161,7 @@ tar archive several times. Each archive member is represented by a
\begin{methoddesc}{open}{...} \begin{methoddesc}{open}{...}
Alternative constructor. The \function{open()} function on module level is Alternative constructor. The \function{open()} function on module level is
actually a shortcut to this classmethod. See section \ref{module-tarfile} actually a shortcut to this classmethod. See section~\ref{module-tarfile}
for details. for details.
\end{methoddesc} \end{methoddesc}
...@@ -187,8 +186,8 @@ tar archive several times. Each archive member is represented by a ...@@ -187,8 +186,8 @@ tar archive several times. Each archive member is represented by a
\begin{methoddesc}{list}{verbose=True} \begin{methoddesc}{list}{verbose=True}
Print a table of contents to \code{sys.stdout}. If \var{verbose} is Print a table of contents to \code{sys.stdout}. If \var{verbose} is
\code{False}, only the names of the members are printed. If it is \constant{False}, only the names of the members are printed. If it is
\code{True}, an \code{"ls -l"}-like output is produced. \constant{True}, output similar to that of \program{ls -l} is produced.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{next}{} \begin{methoddesc}{next}{}
...@@ -219,17 +218,18 @@ tar archive several times. Each archive member is represented by a ...@@ -219,17 +218,18 @@ tar archive several times. Each archive member is represented by a
\end{notice} \end{notice}
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive=True}}} \begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive}}}
Add the file \var{name} to the archive. \var{name} may be any type Add the file \var{name} to the archive. \var{name} may be any type
of file (directory, fifo, symbolic link, etc.). of file (directory, fifo, symbolic link, etc.).
If given, \var{arcname} specifies an alternative name for the file in the If given, \var{arcname} specifies an alternative name for the file in the
archive. Directories are added recursively by default. archive. Directories are added recursively by default.
This can be avoided by setting \var{recursive} to \code{False}. This can be avoided by setting \var{recursive} to \constant{False};
the default is \constant{True}.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{addfile}{tarinfo\optional{, fileobj}} \begin{methoddesc}{addfile}{tarinfo\optional{, fileobj}}
Add the \class{TarInfo} object \var{tarinfo} to the archive. Add the \class{TarInfo} object \var{tarinfo} to the archive.
If \var{fileobj} is given, \code{tarinfo.size} bytes are read If \var{fileobj} is given, \code{\var{tarinfo}.size} bytes are read
from it and added to the archive. You can create \class{TarInfo} objects from it and added to the archive. You can create \class{TarInfo} objects
using \method{gettarinfo()}. using \method{gettarinfo()}.
\begin{notice} \begin{notice}
...@@ -238,57 +238,57 @@ tar archive several times. Each archive member is represented by a ...@@ -238,57 +238,57 @@ tar archive several times. Each archive member is represented by a
\end{notice} \end{notice}
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{gettarinfo}{\optional{name\optional{, arcname \begin{methoddesc}{gettarinfo}{\optional{name\optional{,
\optional{, fileobj}}}} arcname\optional{, fileobj}}}}
Create a \class{TarInfo} object for either the file \var{name} or the Create a \class{TarInfo} object for either the file \var{name} or
file object \var{fileobj} (using \code{os.fstat()} on its file descriptor). the file object \var{fileobj} (using \function{os.fstat()} on its
You can modify some of the \class{TarInfo}'s attributes before you add it file descriptor). You can modify some of the \class{TarInfo}'s
using \method{addfile()}. attributes before you add it using \method{addfile()}. If given,
If given, \var{arcname} specifies an alternative name for the file in the \var{arcname} specifies an alternative name for the file in the
archive. archive.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{close}{} \begin{methoddesc}{close}{}
Close the \class{TarFile}. In write-mode, two finishing zero blocks are Close the \class{TarFile}. In write mode, two finishing zero
appended to the archive. blocks are appended to the archive.
\end{methoddesc} \end{methoddesc}
\begin{memberdesc}{posix=True} \begin{memberdesc}{posix}
If \code{True}, create a POSIX 1003.1-1990 compliant archive. GNU If true, create a \POSIX{} 1003.1-1990 compliant archive. GNU
extensions are not used, because they are not part of the POSIX standard. extensions are not used, because they are not part of the \POSIX{}
This limits the length of filenames to at most 256 and linknames to 100 standard. This limits the length of filenames to at most 256 and
characters. A \exception{ValueError} is raised, if a pathname exceeds this link names to 100 characters. A \exception{ValueError} is raised
limit. if a pathname exceeds this limit. If false, create a GNU tar
If \code{False}, create a GNU tar compatible archive. It will not be POSIX compatible archive. It will not be \POSIX{} compliant, but can
compliant, but can store pathnames of unlimited length. store pathnames of unlimited length.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{dereference=False} \begin{memberdesc}{dereference}
If \code{False}, add symbolic and hard links to archive. If \code{True}, If false, add symbolic and hard links to archive. If true, add the
add the content of the target files to the archive. This has no effect on content of the target files to the archive. This has no effect on
systems that do not support links. systems that do not support symbolic links.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{ignore_zeros=False} \begin{memberdesc}{ignore_zeros}
If \code{False}, treat an empty block as the end of the archive. If If false, treat an empty block as the end of the archive. If true,
\code{True}, skip empty (and invalid) blocks and try to get as many skip empty (and invalid) blocks and try to get as many members as
members as possible. This is only useful for concatenated or damaged possible. This is only useful for concatenated or damaged
archives. archives.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{debug=0} \begin{memberdesc}{debug=0}
To be set from \code{0}(no debug messages) up to \code{3}(all debug To be set from \code{0} (no debug messages; the default) up to
messages). The messages are written to \code{sys.stdout}. \code{3} (all debug messages). The messages are written to
\code{sys.stdout}.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{errorlevel=0} \begin{memberdesc}{errorlevel}
If \code{0}, all errors are ignored when using \method{extract()}. If \code{0} (the default), all errors are ignored when using
Nevertheless, they appear as error messages in the debug output, when \method{extract()}. Nevertheless, they appear as error messages
debugging is enabled. in the debug output, when debugging is enabled. If \code{1}, all
If \code{1}, all \emph{fatal} errors are raised as \exception{OSError} \emph{fatal} errors are raised as \exception{OSError} or
or \exception{IOError} exceptions. \exception{IOError} exceptions. If \code{2}, all \emph{non-fatal}
If \code{2}, all \emph{non-fatal} errors are raised as \exception{TarError} errors are raised as \exception{TarError} exceptions as well.
exceptions as well.
\end{memberdesc} \end{memberdesc}
%----------------- %-----------------
...@@ -297,13 +297,14 @@ tar archive several times. Each archive member is represented by a ...@@ -297,13 +297,14 @@ tar archive several times. Each archive member is represented by a
\subsection{TarInfo Objects \label{tarinfo-objects}} \subsection{TarInfo Objects \label{tarinfo-objects}}
A \class{TarInfo} object represents one member in a \class{TarFile}. Aside from A \class{TarInfo} object represents one member in a
storing all required attributes of a file (like file type, size, time, \class{TarFile}. Aside from storing all required attributes of a file
permissions, owner etc.), it provides some useful methods to determine its (like file type, size, time, permissions, owner etc.), it provides
type. It does \emph{not} contain the file's data itself. some useful methods to determine its type. It does \emph{not} contain
the file's data itself.
\class{TarInfo} objects are returned by \code{TarFile}'s methods \class{TarInfo} objects are returned by \class{TarFile}'s methods
\code{getmember()}, \code{getmembers()} and \code{gettarinfo()}. \method{getmember()}, \method{getmembers()} and \method{gettarinfo()}.
\begin{classdesc}{TarInfo}{\optional{name}} \begin{classdesc}{TarInfo}{\optional{name}}
Create a \class{TarInfo} object. Create a \class{TarInfo} object.
...@@ -318,6 +319,7 @@ type. It does \emph{not} contain the file's data itself. ...@@ -318,6 +319,7 @@ type. It does \emph{not} contain the file's data itself.
\end{methoddesc} \end{methoddesc}
A \code{TarInfo} object has the following public data attributes: A \code{TarInfo} object has the following public data attributes:
\begin{memberdesc}{name} \begin{memberdesc}{name}
Name of the archive member. Name of the archive member.
\end{memberdesc} \end{memberdesc}
...@@ -335,30 +337,42 @@ A \code{TarInfo} object has the following public data attributes: ...@@ -335,30 +337,42 @@ A \code{TarInfo} object has the following public data attributes:
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{type} \begin{memberdesc}{type}
File type. File type. \var{type} is usually one of these constants:
\var{type} is usually one of these constants: \constant{REGTYPE}, \constant{AREGTYPE}, \constant{LNKTYPE},
\code{REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, \constant{SYMTYPE}, \constant{DIRTYPE}, \constant{FIFOTYPE},
CHRTYPE, BLKTYPE, GNUTYPE_SPARSE}. \constant{CONTTYPE}, \constant{CHRTYPE}, \constant{BLKTYPE},
To determine the type of a \class{TarInfo} object more conveniently, use \constant{GNUTYPE_SPARSE}. To determine the type of a
the \code{is_*()} methods below. \class{TarInfo} object more conveniently, use the \code{is_*()}
methods below.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{linkname} \begin{memberdesc}{linkname}
Name of the target file name, which is only present in \class{TarInfo} Name of the target file name, which is only present in
objects of type LNKTYPE and SYMTYPE. \class{TarInfo} objects of type \constant{LNKTYPE} and
\constant{SYMTYPE}.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{uid, gid} \begin{memberdesc}{uid}
User and group ID of who originally stored this member. User ID of the user who originally stored this member.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{uname, gname} \begin{memberdesc}{gid}
User and group name. Group ID of the user who originally stored this member.
\end{memberdesc}
\begin{memberdesc}{uname}
User name.
\end{memberdesc}
\begin{memberdesc}{gname}
Group name.
\end{memberdesc} \end{memberdesc}
A \class{TarInfo} object also provides some convenient query methods: A \class{TarInfo} object also provides some convenient query methods:
\begin{methoddesc}{isfile}{} \begin{methoddesc}{isfile}{}
Return \code{True} if the \class{Tarinfo} object is a regular file. Return \constant{True} if the \class{Tarinfo} object is a regular
file.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{isreg}{} \begin{methoddesc}{isreg}{}
...@@ -366,31 +380,32 @@ A \class{TarInfo} object also provides some convenient query methods: ...@@ -366,31 +380,32 @@ A \class{TarInfo} object also provides some convenient query methods:
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{isdir}{} \begin{methoddesc}{isdir}{}
Return \code{True} if it is a directory. Return \constant{True} if it is a directory.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{issym}{} \begin{methoddesc}{issym}{}
Return \code{True} if it is a symbolic link. Return \constant{True} if it is a symbolic link.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{islnk}{} \begin{methoddesc}{islnk}{}
Return \code{True} if it is a hard link. Return \constant{True} if it is a hard link.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{ischr}{} \begin{methoddesc}{ischr}{}
Return \code{True} if it is a character device. Return \constant{True} if it is a character device.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{isblk}{} \begin{methoddesc}{isblk}{}
Return \code{True} if it is a block device. Return \constant{True} if it is a block device.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{isfifo}{} \begin{methoddesc}{isfifo}{}
Return \code{True} if it is a FIFO. Return \constant{True} if it is a FIFO.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}{isdev}{} \begin{methoddesc}{isdev}{}
Return \code{True} if it is one of character device, block device or FIFO. Return \constant{True} if it is one of character device, block
device or FIFO.
\end{methoddesc} \end{methoddesc}
%------------------------ %------------------------
...@@ -447,4 +462,3 @@ for tarinfo in tar: ...@@ -447,4 +462,3 @@ for tarinfo in tar:
tar.extract(tarinfo) tar.extract(tarinfo)
tar.close() tar.close()
\end{verbatim} \end{verbatim}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment