Lines Matching refs:the
16 by the :func:`fcntl.lockf` call.
20 This module implements some additional functionality over the built-in file
21 objects. In particular, it implements file locking, control over the file
22 flags, and an easy interface to duplicate the file object. The module defines a
23 new file object, the posixfile object. It has all the standard file object
24 methods and adds the methods described below. This module only works for
27 To instantiate a posixfile object, use the :func:`posixfile.open` function. The
28 resulting object looks and feels roughly the same as a standard file object.
30 The :mod:`posixfile` module defines the following constants:
35 Offset is calculated from the start of the file.
40 Offset is calculated from the current position in the file.
45 Offset is calculated from the end of the file.
47 The :mod:`posixfile` module defines the following functions:
52 Create a new posixfile object with the given filename and mode. The *filename*,
53 *mode* and *bufsize* arguments are interpreted the same way as by the built-in
59 Create a new posixfile object with the given standard file object. The resulting
60 object has the same filename and mode as the original file object.
62 The posixfile object defines the following additional methods:
67 Lock the specified section of the file that the file object is referring to.
68 The format is explained below in a table. The *len* argument specifies the
69 length of the section that should be locked. The default is ``0``. *start*
70 specifies the starting offset of the section, where the default is ``0``. The
71 *whence* argument specifies where the offset is relative to. It accepts one of
72 the constants :const:`SEEK_SET`, :const:`SEEK_CUR` or :const:`SEEK_END`. The
73 default is :const:`SEEK_SET`. For more information about the arguments refer to
74 the :manpage:`fcntl(2)` manual page on your system.
79 Set the specified flags for the file that the file object is referring to. The
80 new flags are ORed with the old flags, unless specified otherwise. The format
81 is explained below in a table. Without the *flags* argument a string indicating
82 the current flags is returned (this is the same as the ``?`` modifier). For
83 more information about the flags refer to the :manpage:`fcntl(2)` manual page on
89 Duplicate the file object and the underlying file pointer and file descriptor.
95 Duplicate the file object and the underlying file pointer and file descriptor.
96 The new object will have the given file descriptor. Otherwise the resulting
102 Return the standard file object that the posixfile object is based on. This is
105 All methods raise :exc:`IOError` when the request fails.
107 Format characters for the :meth:`lock` method have the following meaning:
112 | ``u`` | unlock the specified region |
114 | ``r`` | request a read lock for the specified section |
116 | ``w`` | request a write lock for the specified |
120 In addition the following modifiers can be added to the format:
125 | ``|`` | wait until the lock has been | |
128 | ``?`` | return the first lock | \(1) |
129 | | conflicting with the requested | |
137 The lock returned is in the format ``(mode, len, start, whence, pid)`` where
138 *mode* is a character representing the type of lock ('r' or 'w'). This modifier
141 Format characters for the :meth:`flags` method have the following meanings:
155 In addition the following modifiers can be added to the format:
160 | ``!`` | turn the specified flags 'off', | \(1) |
161 | | instead of the default 'on' | |
163 | ``=`` | replace the flags, instead of | \(1) |
164 | | the default 'OR' operation | |
166 | ``?`` | return a string in which the | \(2) |
167 | | characters represent the flags | |
177 This string represents the flags after they may have been altered by the same