Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3bbd115

Browse files
committed
markup changes
1 parent e33aef7 commit 3bbd115

1 file changed

Lines changed: 107 additions & 93 deletions

File tree

Doc/lib/libtarfile.tex

Lines changed: 107 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ \section{\module{tarfile} --- Read and write tar archive files}
1212

1313
\begin{itemize}
1414
\item reads and writes \module{gzip} and \module{bzip2} compressed archives.
15-
\item creates POSIX 1003.1-1990 compliant or GNU tar compatible archives.
15+
\item creates \POSIX{} 1003.1-1990 compliant or GNU tar compatible archives.
1616
\item reads GNU tar extensions \emph{longname}, \emph{longlink} and
1717
\emph{sparse}.
1818
\item stores pathnames of unlimited length using GNU tar extensions.
@@ -52,19 +52,19 @@ \section{\module{tarfile} --- Read and write tar archive files}
5252
a file object opened for \var{name}.
5353

5454
For special purposes, there is a second format for \var{mode}:
55-
\code{'filemode|[compression]'}. \code{open} will return a \class{TarFile}
56-
object that processes its data as a stream of blocks. No random
57-
seeking will be done on the file. If given, \var{fileobj} may be any
58-
object that has a \code{read()} resp. \code{write()} method.
59-
\var{bufsize} specifies the blocksize and defaults to \code{20 * 512}
60-
bytes. Use this variant in combination with e.g. \code{sys.stdin}, a socket
61-
file object or a tape device.
62-
However, such a \class{TarFile} object is limited in that it does not allow
63-
to be accessed randomly, see \citetitle{Examples} (section
64-
\ref{tar-examples}).
65-
The currently possible modes:
66-
67-
\begin{tableii}{c|l}{code}{mode}{action}
55+
\code{'filemode|[compression]'}. \function{open()} will return a
56+
\class{TarFile} object that processes its data as a stream of
57+
blocks. No random seeking will be done on the file. If given,
58+
\var{fileobj} may be any object that has a \method{read()} or
59+
\method{write()} method (depending on the \var{mode}).
60+
\var{bufsize} specifies the blocksize and defaults to \code{20 *
61+
512} bytes. Use this variant in combination with
62+
e.g. \code{sys.stdin}, a socket file object or a tape device.
63+
However, such a \class{TarFile} object is limited in that it does
64+
not allow to be accessed randomly, see ``Examples''
65+
(section~\ref{tar-examples}). The currently possible modes:
66+
67+
\begin{tableii}{c|l}{code}{Mode}{Action}
6868
\lineii{'r|'}{Open a \emph{stream} of uncompressed tar blocks for reading.}
6969
\lineii{'r|gz'}{Open a gzip compressed \emph{stream} for reading.}
7070
\lineii{'r|bz2'}{Open a bzip2 compressed \emph{stream} for reading.}
@@ -77,26 +77,25 @@ \section{\module{tarfile} --- Read and write tar archive files}
7777
\begin{classdesc*}{TarFile}
7878
Class for reading and writing tar archives. Do not use this
7979
class directly, better use \function{open()} instead.
80-
See \citetitle{TarFile Objects} (section \ref{tarfile-objects}).
80+
See ``TarFile Objects'' (section~\ref{tarfile-objects}).
8181
\end{classdesc*}
8282

8383
\begin{funcdesc}{is_tarfile}{name}
84-
Return \code{True} if \var{name} is a tar archive file, that the
85-
\module{tarfile} module can read.
84+
Return \constant{True} if \var{name} is a tar archive file, that
85+
the \module{tarfile} module can read.
8686
\end{funcdesc}
8787

8888
\begin{classdesc}{TarFileCompat}{filename\optional{, mode\optional{,
89-
compression}}}
90-
91-
Class for limited access to tar archives with a \code{zipfile}-like
92-
interface. Please consult the documentation of \code{zipfile} for more
93-
details.
94-
\code{compression} must be one of the following constants:
89+
compression}}}
90+
Class for limited access to tar archives with a
91+
\refmodule{zipfile}-like interface. Please consult the
92+
documentation of the \refmodule{zipfile} module for more details.
93+
\var{compression} must be one of the following constants:
9594
\begin{datadesc}{TAR_PLAIN}
9695
Constant for an uncompressed tar archive.
9796
\end{datadesc}
9897
\begin{datadesc}{TAR_GZIPPED}
99-
Constant for a \code{gzip} compressed tar archive.
98+
Constant for a \refmodule{gzip} compressed tar archive.
10099
\end{datadesc}
101100
\end{classdesc}
102101

@@ -125,7 +124,7 @@ \section{\module{tarfile} --- Read and write tar archive files}
125124
\end{excdesc}
126125

127126
\begin{seealso}
128-
\seemodule{zipfile}{Documentation of the \code{zipfile}
127+
\seemodule{zipfile}{Documentation of the \refmodule{zipfile}
129128
standard module.}
130129

131130
\seetitle[http://www.gnu.org/manual/tar/html_chapter/tar_8.html\#SEC118]
@@ -162,7 +161,7 @@ \subsection{TarFile Objects \label{tarfile-objects}}
162161

163162
\begin{methoddesc}{open}{...}
164163
Alternative constructor. The \function{open()} function on module level is
165-
actually a shortcut to this classmethod. See section \ref{module-tarfile}
164+
actually a shortcut to this classmethod. See section~\ref{module-tarfile}
166165
for details.
167166
\end{methoddesc}
168167

@@ -187,8 +186,8 @@ \subsection{TarFile Objects \label{tarfile-objects}}
187186

188187
\begin{methoddesc}{list}{verbose=True}
189188
Print a table of contents to \code{sys.stdout}. If \var{verbose} is
190-
\code{False}, only the names of the members are printed. If it is
191-
\code{True}, an \code{"ls -l"}-like output is produced.
189+
\constant{False}, only the names of the members are printed. If it is
190+
\constant{True}, output similar to that of \program{ls -l} is produced.
192191
\end{methoddesc}
193192

194193
\begin{methoddesc}{next}{}
@@ -219,17 +218,18 @@ \subsection{TarFile Objects \label{tarfile-objects}}
219218
\end{notice}
220219
\end{methoddesc}
221220

222-
\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive=True}}}
221+
\begin{methoddesc}{add}{name\optional{, arcname\optional{, recursive}}}
223222
Add the file \var{name} to the archive. \var{name} may be any type
224223
of file (directory, fifo, symbolic link, etc.).
225224
If given, \var{arcname} specifies an alternative name for the file in the
226225
archive. Directories are added recursively by default.
227-
This can be avoided by setting \var{recursive} to \code{False}.
226+
This can be avoided by setting \var{recursive} to \constant{False};
227+
the default is \constant{True}.
228228
\end{methoddesc}
229229

230230
\begin{methoddesc}{addfile}{tarinfo\optional{, fileobj}}
231231
Add the \class{TarInfo} object \var{tarinfo} to the archive.
232-
If \var{fileobj} is given, \code{tarinfo.size} bytes are read
232+
If \var{fileobj} is given, \code{\var{tarinfo}.size} bytes are read
233233
from it and added to the archive. You can create \class{TarInfo} objects
234234
using \method{gettarinfo()}.
235235
\begin{notice}
@@ -238,57 +238,57 @@ \subsection{TarFile Objects \label{tarfile-objects}}
238238
\end{notice}
239239
\end{methoddesc}
240240

241-
\begin{methoddesc}{gettarinfo}{\optional{name\optional{, arcname
242-
\optional{, fileobj}}}}
243-
Create a \class{TarInfo} object for either the file \var{name} or the
244-
file object \var{fileobj} (using \code{os.fstat()} on its file descriptor).
245-
You can modify some of the \class{TarInfo}'s attributes before you add it
246-
using \method{addfile()}.
247-
If given, \var{arcname} specifies an alternative name for the file in the
241+
\begin{methoddesc}{gettarinfo}{\optional{name\optional{,
242+
arcname\optional{, fileobj}}}}
243+
Create a \class{TarInfo} object for either the file \var{name} or
244+
the file object \var{fileobj} (using \function{os.fstat()} on its
245+
file descriptor). You can modify some of the \class{TarInfo}'s
246+
attributes before you add it using \method{addfile()}. If given,
247+
\var{arcname} specifies an alternative name for the file in the
248248
archive.
249249
\end{methoddesc}
250250

251251
\begin{methoddesc}{close}{}
252-
Close the \class{TarFile}. In write-mode, two finishing zero blocks are
253-
appended to the archive.
252+
Close the \class{TarFile}. In write mode, two finishing zero
253+
blocks are appended to the archive.
254254
\end{methoddesc}
255255

256-
\begin{memberdesc}{posix=True}
257-
If \code{True}, create a POSIX 1003.1-1990 compliant archive. GNU
258-
extensions are not used, because they are not part of the POSIX standard.
259-
This limits the length of filenames to at most 256 and linknames to 100
260-
characters. A \exception{ValueError} is raised, if a pathname exceeds this
261-
limit.
262-
If \code{False}, create a GNU tar compatible archive. It will not be POSIX
263-
compliant, but can store pathnames of unlimited length.
256+
\begin{memberdesc}{posix}
257+
If true, create a \POSIX{} 1003.1-1990 compliant archive. GNU
258+
extensions are not used, because they are not part of the \POSIX{}
259+
standard. This limits the length of filenames to at most 256 and
260+
link names to 100 characters. A \exception{ValueError} is raised
261+
if a pathname exceeds this limit. If false, create a GNU tar
262+
compatible archive. It will not be \POSIX{} compliant, but can
263+
store pathnames of unlimited length.
264264
\end{memberdesc}
265265

266-
\begin{memberdesc}{dereference=False}
267-
If \code{False}, add symbolic and hard links to archive. If \code{True},
268-
add the content of the target files to the archive. This has no effect on
269-
systems that do not support links.
266+
\begin{memberdesc}{dereference}
267+
If false, add symbolic and hard links to archive. If true, add the
268+
content of the target files to the archive. This has no effect on
269+
systems that do not support symbolic links.
270270
\end{memberdesc}
271271

272-
\begin{memberdesc}{ignore_zeros=False}
273-
If \code{False}, treat an empty block as the end of the archive. If
274-
\code{True}, skip empty (and invalid) blocks and try to get as many
275-
members as possible. This is only useful for concatenated or damaged
272+
\begin{memberdesc}{ignore_zeros}
273+
If false, treat an empty block as the end of the archive. If true,
274+
skip empty (and invalid) blocks and try to get as many members as
275+
possible. This is only useful for concatenated or damaged
276276
archives.
277277
\end{memberdesc}
278278

279279
\begin{memberdesc}{debug=0}
280-
To be set from \code{0}(no debug messages) up to \code{3}(all debug
281-
messages). The messages are written to \code{sys.stdout}.
280+
To be set from \code{0} (no debug messages; the default) up to
281+
\code{3} (all debug messages). The messages are written to
282+
\code{sys.stdout}.
282283
\end{memberdesc}
283284

284-
\begin{memberdesc}{errorlevel=0}
285-
If \code{0}, all errors are ignored when using \method{extract()}.
286-
Nevertheless, they appear as error messages in the debug output, when
287-
debugging is enabled.
288-
If \code{1}, all \emph{fatal} errors are raised as \exception{OSError}
289-
or \exception{IOError} exceptions.
290-
If \code{2}, all \emph{non-fatal} errors are raised as \exception{TarError}
291-
exceptions as well.
285+
\begin{memberdesc}{errorlevel}
286+
If \code{0} (the default), all errors are ignored when using
287+
\method{extract()}. Nevertheless, they appear as error messages
288+
in the debug output, when debugging is enabled. If \code{1}, all
289+
\emph{fatal} errors are raised as \exception{OSError} or
290+
\exception{IOError} exceptions. If \code{2}, all \emph{non-fatal}
291+
errors are raised as \exception{TarError} exceptions as well.
292292
\end{memberdesc}
293293

294294
%-----------------
@@ -297,13 +297,14 @@ \subsection{TarFile Objects \label{tarfile-objects}}
297297

298298
\subsection{TarInfo Objects \label{tarinfo-objects}}
299299

300-
A \class{TarInfo} object represents one member in a \class{TarFile}. Aside from
301-
storing all required attributes of a file (like file type, size, time,
302-
permissions, owner etc.), it provides some useful methods to determine its
303-
type. It does \emph{not} contain the file's data itself.
300+
A \class{TarInfo} object represents one member in a
301+
\class{TarFile}. Aside from storing all required attributes of a file
302+
(like file type, size, time, permissions, owner etc.), it provides
303+
some useful methods to determine its type. It does \emph{not} contain
304+
the file's data itself.
304305

305-
\class{TarInfo} objects are returned by \code{TarFile}'s methods
306-
\code{getmember()}, \code{getmembers()} and \code{gettarinfo()}.
306+
\class{TarInfo} objects are returned by \class{TarFile}'s methods
307+
\method{getmember()}, \method{getmembers()} and \method{gettarinfo()}.
307308

308309
\begin{classdesc}{TarInfo}{\optional{name}}
309310
Create a \class{TarInfo} object.
@@ -318,6 +319,7 @@ \subsection{TarInfo Objects \label{tarinfo-objects}}
318319
\end{methoddesc}
319320

320321
A \code{TarInfo} object has the following public data attributes:
322+
321323
\begin{memberdesc}{name}
322324
Name of the archive member.
323325
\end{memberdesc}
@@ -335,62 +337,75 @@ \subsection{TarInfo Objects \label{tarinfo-objects}}
335337
\end{memberdesc}
336338

337339
\begin{memberdesc}{type}
338-
File type.
339-
\var{type} is usually one of these constants:
340-
\code{REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE,
341-
CHRTYPE, BLKTYPE, GNUTYPE_SPARSE}.
342-
To determine the type of a \class{TarInfo} object more conveniently, use
343-
the \code{is_*()} methods below.
340+
File type. \var{type} is usually one of these constants:
341+
\constant{REGTYPE}, \constant{AREGTYPE}, \constant{LNKTYPE},
342+
\constant{SYMTYPE}, \constant{DIRTYPE}, \constant{FIFOTYPE},
343+
\constant{CONTTYPE}, \constant{CHRTYPE}, \constant{BLKTYPE},
344+
\constant{GNUTYPE_SPARSE}. To determine the type of a
345+
\class{TarInfo} object more conveniently, use the \code{is_*()}
346+
methods below.
344347
\end{memberdesc}
345348

346349
\begin{memberdesc}{linkname}
347-
Name of the target file name, which is only present in \class{TarInfo}
348-
objects of type LNKTYPE and SYMTYPE.
350+
Name of the target file name, which is only present in
351+
\class{TarInfo} objects of type \constant{LNKTYPE} and
352+
\constant{SYMTYPE}.
349353
\end{memberdesc}
350354

351-
\begin{memberdesc}{uid, gid}
352-
User and group ID of who originally stored this member.
355+
\begin{memberdesc}{uid}
356+
User ID of the user who originally stored this member.
353357
\end{memberdesc}
354358

355-
\begin{memberdesc}{uname, gname}
356-
User and group name.
359+
\begin{memberdesc}{gid}
360+
Group ID of the user who originally stored this member.
361+
\end{memberdesc}
362+
363+
\begin{memberdesc}{uname}
364+
User name.
365+
\end{memberdesc}
366+
367+
\begin{memberdesc}{gname}
368+
Group name.
357369
\end{memberdesc}
358370

359371
A \class{TarInfo} object also provides some convenient query methods:
372+
360373
\begin{methoddesc}{isfile}{}
361-
Return \code{True} if the \class{Tarinfo} object is a regular file.
374+
Return \constant{True} if the \class{Tarinfo} object is a regular
375+
file.
362376
\end{methoddesc}
363377

364378
\begin{methoddesc}{isreg}{}
365379
Same as \method{isfile()}.
366380
\end{methoddesc}
367381

368382
\begin{methoddesc}{isdir}{}
369-
Return \code{True} if it is a directory.
383+
Return \constant{True} if it is a directory.
370384
\end{methoddesc}
371385

372386
\begin{methoddesc}{issym}{}
373-
Return \code{True} if it is a symbolic link.
387+
Return \constant{True} if it is a symbolic link.
374388
\end{methoddesc}
375389

376390
\begin{methoddesc}{islnk}{}
377-
Return \code{True} if it is a hard link.
391+
Return \constant{True} if it is a hard link.
378392
\end{methoddesc}
379393

380394
\begin{methoddesc}{ischr}{}
381-
Return \code{True} if it is a character device.
395+
Return \constant{True} if it is a character device.
382396
\end{methoddesc}
383397

384398
\begin{methoddesc}{isblk}{}
385-
Return \code{True} if it is a block device.
399+
Return \constant{True} if it is a block device.
386400
\end{methoddesc}
387401

388402
\begin{methoddesc}{isfifo}{}
389-
Return \code{True} if it is a FIFO.
403+
Return \constant{True} if it is a FIFO.
390404
\end{methoddesc}
391405

392406
\begin{methoddesc}{isdev}{}
393-
Return \code{True} if it is one of character device, block device or FIFO.
407+
Return \constant{True} if it is one of character device, block
408+
device or FIFO.
394409
\end{methoddesc}
395410

396411
%------------------------
@@ -447,4 +462,3 @@ \subsection{Examples \label{tar-examples}}
447462
tar.extract(tarinfo)
448463
tar.close()
449464
\end{verbatim}
450-

0 commit comments

Comments
 (0)