Logical markup.

Changed example to use "import posixfile" instead of "from posixfile import *"
since only one symbol was used.
This commit is contained in:
Fred Drake 1998-03-11 06:11:37 +00:00
parent e42f595e5c
commit 295eaa84b0
2 changed files with 60 additions and 54 deletions

View file

@ -6,7 +6,8 @@
\emph{Note:} This module will become obsolete in a future release. \emph{Note:} This module will become obsolete in a future release.
The locking operation that it provides is done better and more The locking operation that it provides is done better and more
portably by the \code{fcntl.lockf()} call. portably by the \function{fcntl.lockf()} call.%
\index{lockf()@\idxcode{lockf()} (in module fcntl)}
This module implements some additional functionality over the built-in This module implements some additional functionality over the built-in
file objects. In particular, it implements file locking, control over file objects. In particular, it implements file locking, control over
@ -14,15 +15,15 @@ the file flags, and an easy interface to duplicate the file object.
The module defines a new file object, the posixfile object. It The module defines a new file object, the posixfile object. It
has all the standard file object methods and adds the methods has all the standard file object methods and adds the methods
described below. This module only works for certain flavors of described below. This module only works for certain flavors of
\UNIX{}, since it uses \code{fcntl()} for file locking. \UNIX{}, since it uses \function{fcntl()} for file locking.
To instantiate a posixfile object, use the \code{open()} function in To instantiate a posixfile object, use the \function{open()} function
the posixfile module. The resulting object looks and feels roughly in the \module{posixfile} module. The resulting object looks and
the same as a standard file object. feels roughly the same as a standard file object.
The \module{posixfile} module defines the following constants:
The posixfile module defines the following constants:
\setindexsubitem{(in module posixfile)}
\begin{datadesc}{SEEK_SET} \begin{datadesc}{SEEK_SET}
Offset is calculated from the start of the file. Offset is calculated from the start of the file.
\end{datadesc} \end{datadesc}
@ -35,14 +36,14 @@ Offset is calculated from the current position in the file.
Offset is calculated from the end of the file. Offset is calculated from the end of the file.
\end{datadesc} \end{datadesc}
The posixfile module defines the following functions: The \module{posixfile} module defines the following functions:
\setindexsubitem{(in module posixfile)}
\begin{funcdesc}{open}{filename\optional{\, mode\optional{\, bufsize}}} \begin{funcdesc}{open}{filename\optional{, mode\optional{, bufsize}}}
Create a new posixfile object with the given filename and mode. The Create a new posixfile object with the given filename and mode. The
\var{filename}, \var{mode} and \var{bufsize} arguments are \var{filename}, \var{mode} and \var{bufsize} arguments are
interpreted the same way as by the built-in \code{open()} function. interpreted the same way as by the built-in \function{open()}
function.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{fileopen}{fileobject} \begin{funcdesc}{fileopen}{fileobject}
@ -54,17 +55,17 @@ The posixfile module defines the following functions:
The posixfile object defines the following additional methods: The posixfile object defines the following additional methods:
\setindexsubitem{(posixfile method)} \setindexsubitem{(posixfile method)}
\begin{funcdesc}{lock}{fmt\, \optional{len\optional{\, start\optional{\, whence}}}} \begin{funcdesc}{lock}{fmt, \optional{len\optional{, start\optional{, whence}}}}
Lock the specified section of the file that the file object is Lock the specified section of the file that the file object is
referring to. The format is explained referring to. The format is explained
below in a table. The \var{len} argument specifies the length of the below in a table. The \var{len} argument specifies the length of the
section that should be locked. The default is \code{0}. \var{start} section that should be locked. The default is \code{0}. \var{start}
specifies the starting offset of the section, where the default is specifies the starting offset of the section, where the default is
\code{0}. The \var{whence} argument specifies where the offset is \code{0}. The \var{whence} argument specifies where the offset is
relative to. It accepts one of the constants \code{SEEK_SET}, relative to. It accepts one of the constants \constant{SEEK_SET},
\code{SEEK_CUR} or \code{SEEK_END}. The default is \code{SEEK_SET}. \constant{SEEK_CUR} or \constant{SEEK_END}. The default is
For more information about the arguments refer to the fcntl \constant{SEEK_SET}. For more information about the arguments refer
manual page on your system. to the \manpage{fcntl}{2} manual page on your system.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{flags}{\optional{flags}} \begin{funcdesc}{flags}{\optional{flags}}
@ -73,8 +74,8 @@ The posixfile object defines the following additional methods:
otherwise. The format is explained below in a table. Without otherwise. The format is explained below in a table. Without
the \var{flags} argument the \var{flags} argument
a string indicating the current flags is returned (this is a string indicating the current flags is returned (this is
the same as the '?' modifier). For more information about the flags the same as the \samp{?} modifier). For more information about the
refer to the fcntl manual page on your system. flags refer to the \manpage{fcntl}{2} manual page on your system.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{dup}{} \begin{funcdesc}{dup}{}
@ -95,9 +96,10 @@ The posixfile object defines the following additional methods:
standard file object. standard file object.
\end{funcdesc} \end{funcdesc}
All methods return \code{IOError} when the request fails. All methods raise \exception{IOError} when the request fails.
Format characters for the \code{lock()} method have the following meaning: Format characters for the \method{lock()} method have the following
meaning:
\begin{tableii}{|c|l|}{samp}{Format}{Meaning} \begin{tableii}{|c|l|}{samp}{Format}{Meaning}
\lineii{u}{unlock the specified region} \lineii{u}{unlock the specified region}
@ -115,12 +117,13 @@ In addition the following modifiers can be added to the format:
Note: Note:
(1) The lock returned is in the format \code{(mode, len, start, (1) The lock returned is in the format \code{(\var{mode}, \var{len},
whence, pid)} where mode is a character representing the type of lock \var{start}, \var{whence}, \var{pid})} where \var{mode} is a character
('r' or 'w'). This modifier prevents a request from being granted; it representing the type of lock ('r' or 'w'). This modifier prevents a
is for query purposes only. request from being granted; it is for query purposes only.
Format character for the \code{flags()} method have the following meaning: Format characters for the \method{flags()} method have the following
meanings:
\begin{tableii}{|c|l|}{samp}{Format}{Meaning} \begin{tableii}{|c|l|}{samp}{Format}{Meaning}
\lineii{a}{append only flag} \lineii{a}{append only flag}
@ -148,9 +151,9 @@ by the same call.
Examples: Examples:
\begin{verbatim} \begin{verbatim}
from posixfile import * import posixfile
file = open('/tmp/test', 'w') file = posixfile.open('/tmp/test', 'w')
file.lock('w|') file.lock('w|')
... ...
file.lock('u') file.lock('u')

View file

@ -6,7 +6,8 @@
\emph{Note:} This module will become obsolete in a future release. \emph{Note:} This module will become obsolete in a future release.
The locking operation that it provides is done better and more The locking operation that it provides is done better and more
portably by the \code{fcntl.lockf()} call. portably by the \function{fcntl.lockf()} call.%
\index{lockf()@\idxcode{lockf()} (in module fcntl)}
This module implements some additional functionality over the built-in This module implements some additional functionality over the built-in
file objects. In particular, it implements file locking, control over file objects. In particular, it implements file locking, control over
@ -14,15 +15,15 @@ the file flags, and an easy interface to duplicate the file object.
The module defines a new file object, the posixfile object. It The module defines a new file object, the posixfile object. It
has all the standard file object methods and adds the methods has all the standard file object methods and adds the methods
described below. This module only works for certain flavors of described below. This module only works for certain flavors of
\UNIX{}, since it uses \code{fcntl()} for file locking. \UNIX{}, since it uses \function{fcntl()} for file locking.
To instantiate a posixfile object, use the \code{open()} function in To instantiate a posixfile object, use the \function{open()} function
the posixfile module. The resulting object looks and feels roughly in the \module{posixfile} module. The resulting object looks and
the same as a standard file object. feels roughly the same as a standard file object.
The \module{posixfile} module defines the following constants:
The posixfile module defines the following constants:
\setindexsubitem{(in module posixfile)}
\begin{datadesc}{SEEK_SET} \begin{datadesc}{SEEK_SET}
Offset is calculated from the start of the file. Offset is calculated from the start of the file.
\end{datadesc} \end{datadesc}
@ -35,14 +36,14 @@ Offset is calculated from the current position in the file.
Offset is calculated from the end of the file. Offset is calculated from the end of the file.
\end{datadesc} \end{datadesc}
The posixfile module defines the following functions: The \module{posixfile} module defines the following functions:
\setindexsubitem{(in module posixfile)}
\begin{funcdesc}{open}{filename\optional{\, mode\optional{\, bufsize}}} \begin{funcdesc}{open}{filename\optional{, mode\optional{, bufsize}}}
Create a new posixfile object with the given filename and mode. The Create a new posixfile object with the given filename and mode. The
\var{filename}, \var{mode} and \var{bufsize} arguments are \var{filename}, \var{mode} and \var{bufsize} arguments are
interpreted the same way as by the built-in \code{open()} function. interpreted the same way as by the built-in \function{open()}
function.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{fileopen}{fileobject} \begin{funcdesc}{fileopen}{fileobject}
@ -54,17 +55,17 @@ The posixfile module defines the following functions:
The posixfile object defines the following additional methods: The posixfile object defines the following additional methods:
\setindexsubitem{(posixfile method)} \setindexsubitem{(posixfile method)}
\begin{funcdesc}{lock}{fmt\, \optional{len\optional{\, start\optional{\, whence}}}} \begin{funcdesc}{lock}{fmt, \optional{len\optional{, start\optional{, whence}}}}
Lock the specified section of the file that the file object is Lock the specified section of the file that the file object is
referring to. The format is explained referring to. The format is explained
below in a table. The \var{len} argument specifies the length of the below in a table. The \var{len} argument specifies the length of the
section that should be locked. The default is \code{0}. \var{start} section that should be locked. The default is \code{0}. \var{start}
specifies the starting offset of the section, where the default is specifies the starting offset of the section, where the default is
\code{0}. The \var{whence} argument specifies where the offset is \code{0}. The \var{whence} argument specifies where the offset is
relative to. It accepts one of the constants \code{SEEK_SET}, relative to. It accepts one of the constants \constant{SEEK_SET},
\code{SEEK_CUR} or \code{SEEK_END}. The default is \code{SEEK_SET}. \constant{SEEK_CUR} or \constant{SEEK_END}. The default is
For more information about the arguments refer to the fcntl \constant{SEEK_SET}. For more information about the arguments refer
manual page on your system. to the \manpage{fcntl}{2} manual page on your system.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{flags}{\optional{flags}} \begin{funcdesc}{flags}{\optional{flags}}
@ -73,8 +74,8 @@ The posixfile object defines the following additional methods:
otherwise. The format is explained below in a table. Without otherwise. The format is explained below in a table. Without
the \var{flags} argument the \var{flags} argument
a string indicating the current flags is returned (this is a string indicating the current flags is returned (this is
the same as the '?' modifier). For more information about the flags the same as the \samp{?} modifier). For more information about the
refer to the fcntl manual page on your system. flags refer to the \manpage{fcntl}{2} manual page on your system.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{dup}{} \begin{funcdesc}{dup}{}
@ -95,9 +96,10 @@ The posixfile object defines the following additional methods:
standard file object. standard file object.
\end{funcdesc} \end{funcdesc}
All methods return \code{IOError} when the request fails. All methods raise \exception{IOError} when the request fails.
Format characters for the \code{lock()} method have the following meaning: Format characters for the \method{lock()} method have the following
meaning:
\begin{tableii}{|c|l|}{samp}{Format}{Meaning} \begin{tableii}{|c|l|}{samp}{Format}{Meaning}
\lineii{u}{unlock the specified region} \lineii{u}{unlock the specified region}
@ -115,12 +117,13 @@ In addition the following modifiers can be added to the format:
Note: Note:
(1) The lock returned is in the format \code{(mode, len, start, (1) The lock returned is in the format \code{(\var{mode}, \var{len},
whence, pid)} where mode is a character representing the type of lock \var{start}, \var{whence}, \var{pid})} where \var{mode} is a character
('r' or 'w'). This modifier prevents a request from being granted; it representing the type of lock ('r' or 'w'). This modifier prevents a
is for query purposes only. request from being granted; it is for query purposes only.
Format character for the \code{flags()} method have the following meaning: Format characters for the \method{flags()} method have the following
meanings:
\begin{tableii}{|c|l|}{samp}{Format}{Meaning} \begin{tableii}{|c|l|}{samp}{Format}{Meaning}
\lineii{a}{append only flag} \lineii{a}{append only flag}
@ -148,9 +151,9 @@ by the same call.
Examples: Examples:
\begin{verbatim} \begin{verbatim}
from posixfile import * import posixfile
file = open('/tmp/test', 'w') file = posixfile.open('/tmp/test', 'w')
file.lock('w|') file.lock('w|')
... ...
file.lock('u') file.lock('u')