[Python-3000-checkins] r55742 - in python/branches/p3yk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libposixfile.tex Lib/posixfile.py Lib/test/test_sundry.py Misc/cheatsheet
neal.norwitz
python-3000-checkins at python.org
Sat Jun 2 09:51:45 CEST 2007
Author: neal.norwitz
Date: Sat Jun 2 09:51:44 2007
New Revision: 55742
Removed:
python/branches/p3yk/Doc/lib/libposixfile.tex
python/branches/p3yk/Lib/posixfile.py
Modified:
python/branches/p3yk/Doc/Makefile.deps
python/branches/p3yk/Doc/lib/lib.tex
python/branches/p3yk/Lib/test/test_sundry.py
python/branches/p3yk/Misc/cheatsheet
Log:
Remove posixfile module (plus some remnants of other modules).
Modified: python/branches/p3yk/Doc/Makefile.deps
==============================================================================
--- python/branches/p3yk/Doc/Makefile.deps (original)
+++ python/branches/p3yk/Doc/Makefile.deps Sat Jun 2 09:51:44 2007
@@ -171,7 +171,6 @@
lib/libgdbm.tex \
lib/libtermios.tex \
lib/libfcntl.tex \
- lib/libposixfile.tex \
lib/libsyslog.tex \
lib/liblogging.tex \
lib/libpdb.tex \
Modified: python/branches/p3yk/Doc/lib/lib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/lib.tex (original)
+++ python/branches/p3yk/Doc/lib/lib.tex Sat Jun 2 09:51:44 2007
@@ -263,7 +263,6 @@
\input{libpty}
\input{libfcntl}
\input{libpipes}
-\input{libposixfile}
\input{libresource}
\input{libnis}
\input{libsyslog}
Deleted: /python/branches/p3yk/Doc/lib/libposixfile.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libposixfile.tex Sat Jun 2 09:51:44 2007
+++ (empty file)
@@ -1,174 +0,0 @@
-% Manual text and implementation by Jaap Vermeulen
-\section{\module{posixfile} ---
- File-like objects with locking support}
-
-\declaremodule{builtin}{posixfile}
- \platform{Unix}
-\modulesynopsis{A file-like object with support for locking.}
-\moduleauthor{Jaap Vermeulen}{}
-\sectionauthor{Jaap Vermeulen}{}
-
-
-\indexii{\POSIX}{file object}
-
-\deprecated{1.5}{The locking operation that this module provides is
-done better and more portably by the
-\function{\refmodule{fcntl}.lockf()} call.
-\withsubitem{(in module fcntl)}{\ttindex{lockf()}}}
-
-This module implements some additional functionality over the built-in
-file objects. In particular, it implements file locking, control over
-the file flags, and an easy interface to duplicate the file object.
-The module defines a new file object, the posixfile object. It
-has all the standard file object methods and adds the methods
-described below. This module only works for certain flavors of
-\UNIX, since it uses \function{fcntl.fcntl()} for file locking.%
-\withsubitem{(in module fcntl)}{\ttindex{fcntl()}}
-
-To instantiate a posixfile object, use the \function{open()} function
-in the \module{posixfile} module. The resulting object looks and
-feels roughly the same as a standard file object.
-
-The \module{posixfile} module defines the following constants:
-
-
-\begin{datadesc}{SEEK_SET}
-Offset is calculated from the start of the file.
-\end{datadesc}
-
-\begin{datadesc}{SEEK_CUR}
-Offset is calculated from the current position in the file.
-\end{datadesc}
-
-\begin{datadesc}{SEEK_END}
-Offset is calculated from the end of the file.
-\end{datadesc}
-
-The \module{posixfile} module defines the following functions:
-
-
-\begin{funcdesc}{open}{filename\optional{, mode\optional{, bufsize}}}
- Create a new posixfile object with the given filename and mode. The
- \var{filename}, \var{mode} and \var{bufsize} arguments are
- interpreted the same way as by the built-in \function{open()}
- function.
-\end{funcdesc}
-
-\begin{funcdesc}{fileopen}{fileobject}
- Create a new posixfile object with the given standard file object.
- The resulting object has the same filename and mode as the original
- file object.
-\end{funcdesc}
-
-The posixfile object defines the following additional methods:
-
-\begin{methoddesc}[posixfile]{lock}{fmt, \optional{len\optional{, start\optional{, whence}}}}
- Lock the specified section of the file that the file object is
- referring to. The format is explained
- 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}
- specifies the starting offset of the section, where the default is
- \code{0}. The \var{whence} argument specifies where the offset is
- relative to. It accepts one of the constants \constant{SEEK_SET},
- \constant{SEEK_CUR} or \constant{SEEK_END}. The default is
- \constant{SEEK_SET}. For more information about the arguments refer
- to the \manpage{fcntl}{2} manual page on your system.
-\end{methoddesc}
-
-\begin{methoddesc}[posixfile]{flags}{\optional{flags}}
- Set the specified flags for the file that the file object is referring
- to. The new flags are ORed with the old flags, unless specified
- otherwise. The format is explained below in a table. Without
- the \var{flags} argument
- a string indicating the current flags is returned (this is
- the same as the \samp{?} modifier). For more information about the
- flags refer to the \manpage{fcntl}{2} manual page on your system.
-\end{methoddesc}
-
-\begin{methoddesc}[posixfile]{dup}{}
- Duplicate the file object and the underlying file pointer and file
- descriptor. The resulting object behaves as if it were newly
- opened.
-\end{methoddesc}
-
-\begin{methoddesc}[posixfile]{dup2}{fd}
- Duplicate the file object and the underlying file pointer and file
- descriptor. The new object will have the given file descriptor.
- Otherwise the resulting object behaves as if it were newly opened.
-\end{methoddesc}
-
-\begin{methoddesc}[posixfile]{file}{}
- Return the standard file object that the posixfile object is based
- on. This is sometimes necessary for functions that insist on a
- standard file object.
-\end{methoddesc}
-
-All methods raise \exception{IOError} when the request fails.
-
-Format characters for the \method{lock()} method have the following
-meaning:
-
-\begin{tableii}{c|l}{samp}{Format}{Meaning}
- \lineii{u}{unlock the specified region}
- \lineii{r}{request a read lock for the specified section}
- \lineii{w}{request a write lock for the specified section}
-\end{tableii}
-
-In addition the following modifiers can be added to the format:
-
-\begin{tableiii}{c|l|c}{samp}{Modifier}{Meaning}{Notes}
- \lineiii{|}{wait until the lock has been granted}{}
- \lineiii{?}{return the first lock conflicting with the requested lock, or
- \code{None} if there is no conflict.}{(1)}
-\end{tableiii}
-
-\noindent
-Note:
-
-\begin{description}
-\item[(1)] The lock returned is in the format \code{(\var{mode}, \var{len},
-\var{start}, \var{whence}, \var{pid})} where \var{mode} is a character
-representing the type of lock ('r' or 'w'). This modifier prevents a
-request from being granted; it is for query purposes only.
-\end{description}
-
-Format characters for the \method{flags()} method have the following
-meanings:
-
-\begin{tableii}{c|l}{samp}{Format}{Meaning}
- \lineii{a}{append only flag}
- \lineii{c}{close on exec flag}
- \lineii{n}{no delay flag (also called non-blocking flag)}
- \lineii{s}{synchronization flag}
-\end{tableii}
-
-In addition the following modifiers can be added to the format:
-
-\begin{tableiii}{c|l|c}{samp}{Modifier}{Meaning}{Notes}
- \lineiii{!}{turn the specified flags 'off', instead of the default 'on'}{(1)}
- \lineiii{=}{replace the flags, instead of the default 'OR' operation}{(1)}
- \lineiii{?}{return a string in which the characters represent the flags that
- are set.}{(2)}
-\end{tableiii}
-
-\noindent
-Notes:
-
-\begin{description}
-\item[(1)] The \samp{!} and \samp{=} modifiers are mutually exclusive.
-
-\item[(2)] This string represents the flags after they may have been altered
-by the same call.
-\end{description}
-
-Examples:
-
-\begin{verbatim}
-import posixfile
-
-file = posixfile.open('/tmp/test', 'w')
-file.lock('w|')
-...
-file.lock('u')
-file.close()
-\end{verbatim}
Deleted: /python/branches/p3yk/Lib/posixfile.py
==============================================================================
--- /python/branches/p3yk/Lib/posixfile.py Sat Jun 2 09:51:44 2007
+++ (empty file)
@@ -1,237 +0,0 @@
-"""Extended file operations available in POSIX.
-
-f = posixfile.open(filename, [mode, [bufsize]])
- will create a new posixfile object
-
-f = posixfile.fileopen(fileobject)
- will create a posixfile object from a builtin file object
-
-f.file()
- will return the original builtin file object
-
-f.dup()
- will return a new file object based on a new filedescriptor
-
-f.dup2(fd)
- will return a new file object based on the given filedescriptor
-
-f.flags(mode)
- will turn on the associated flag (merge)
- mode can contain the following characters:
-
- (character representing a flag)
- a append only flag
- c close on exec flag
- n no delay flag
- s synchronization flag
- (modifiers)
- ! turn flags 'off' instead of default 'on'
- = copy flags 'as is' instead of default 'merge'
- ? return a string in which the characters represent the flags
- that are set
-
- note: - the '!' and '=' modifiers are mutually exclusive.
- - the '?' modifier will return the status of the flags after they
- have been changed by other characters in the mode string
-
-f.lock(mode [, len [, start [, whence]]])
- will (un)lock a region
- mode can contain the following characters:
-
- (character representing type of lock)
- u unlock
- r read lock
- w write lock
- (modifiers)
- | wait until the lock can be granted
- ? return the first lock conflicting with the requested lock
- or 'None' if there is no conflict. The lock returned is in the
- format (mode, len, start, whence, pid) where mode is a
- character representing the type of lock ('r' or 'w')
-
- note: - the '?' modifier prevents a region from being locked; it is
- query only
-"""
-import warnings
-warnings.warn("The posixfile module is deprecated; "
- "fcntl.lockf() provides better locking", DeprecationWarning, 2)
-
-class _posixfile_:
- """File wrapper class that provides extra POSIX file routines."""
-
- states = ['open', 'closed']
-
- #
- # Internal routines
- #
- def __repr__(self):
- file = self._file_
- return "<%s posixfile '%s', mode '%s' at %s>" % \
- (self.states[file.closed], file.name, file.mode, \
- hex(id(self))[2:])
-
- #
- # Initialization routines
- #
- def open(self, name, mode='r', bufsize=-1):
- import __builtin__
- return self.fileopen(__builtin__.open(name, mode, bufsize))
-
- def fileopen(self, file):
- import types
- if repr(type(file)) != "<type 'file'>":
- raise TypeError, 'posixfile.fileopen() arg must be file object'
- self._file_ = file
- # Copy basic file methods
- for maybemethod in dir(file):
- if not maybemethod.startswith('_'):
- attr = getattr(file, maybemethod)
- if isinstance(attr, types.BuiltinMethodType):
- setattr(self, maybemethod, attr)
- return self
-
- #
- # New methods
- #
- def file(self):
- return self._file_
-
- def dup(self):
- import posix
-
- if not hasattr(posix, 'fdopen'):
- raise AttributeError, 'dup() method unavailable'
-
- return posix.fdopen(posix.dup(self._file_.fileno()), self._file_.mode)
-
- def dup2(self, fd):
- import posix
-
- if not hasattr(posix, 'fdopen'):
- raise AttributeError, 'dup() method unavailable'
-
- posix.dup2(self._file_.fileno(), fd)
- return posix.fdopen(fd, self._file_.mode)
-
- def flags(self, *which):
- import fcntl, os
-
- if which:
- if len(which) > 1:
- raise TypeError, 'Too many arguments'
- which = which[0]
- else: which = '?'
-
- l_flags = 0
- if 'n' in which: l_flags = l_flags | os.O_NDELAY
- if 'a' in which: l_flags = l_flags | os.O_APPEND
- if 's' in which: l_flags = l_flags | os.O_SYNC
-
- file = self._file_
-
- if '=' not in which:
- cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
- if '!' in which: l_flags = cur_fl & ~ l_flags
- else: l_flags = cur_fl | l_flags
-
- l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags)
-
- if 'c' in which:
- arg = ('!' not in which) # 0 is don't, 1 is do close on exec
- l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg)
-
- if '?' in which:
- which = '' # Return current flags
- l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
- if os.O_APPEND & l_flags: which = which + 'a'
- if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1:
- which = which + 'c'
- if os.O_NDELAY & l_flags: which = which + 'n'
- if os.O_SYNC & l_flags: which = which + 's'
- return which
-
- def lock(self, how, *args):
- import struct, fcntl
-
- if 'w' in how: l_type = fcntl.F_WRLCK
- elif 'r' in how: l_type = fcntl.F_RDLCK
- elif 'u' in how: l_type = fcntl.F_UNLCK
- else: raise TypeError, 'no type of lock specified'
-
- if '|' in how: cmd = fcntl.F_SETLKW
- elif '?' in how: cmd = fcntl.F_GETLK
- else: cmd = fcntl.F_SETLK
-
- l_whence = 0
- l_start = 0
- l_len = 0
-
- if len(args) == 1:
- l_len = args[0]
- elif len(args) == 2:
- l_len, l_start = args
- elif len(args) == 3:
- l_len, l_start, l_whence = args
- elif len(args) > 3:
- raise TypeError, 'too many arguments'
-
- # Hack by davem at magnet.com to get locking to go on freebsd;
- # additions for AIX by Vladimir.Marangozov at imag.fr
- import sys, os
- if sys.platform in ('netbsd1',
- 'openbsd2',
- 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
- 'freebsd6', 'freebsd7',
- 'bsdos2', 'bsdos3', 'bsdos4'):
- flock = struct.pack('lxxxxlxxxxlhh', \
- l_start, l_len, os.getpid(), l_type, l_whence)
- elif sys.platform in ('aix3', 'aix4'):
- flock = struct.pack('hhlllii', \
- l_type, l_whence, l_start, l_len, 0, 0, 0)
- else:
- flock = struct.pack('hhllhh', \
- l_type, l_whence, l_start, l_len, 0, 0)
-
- flock = fcntl.fcntl(self._file_.fileno(), cmd, flock)
-
- if '?' in how:
- if sys.platform in ('netbsd1',
- 'openbsd2',
- 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
- 'bsdos2', 'bsdos3', 'bsdos4'):
- l_start, l_len, l_pid, l_type, l_whence = \
- struct.unpack('lxxxxlxxxxlhh', flock)
- elif sys.platform in ('aix3', 'aix4'):
- l_type, l_whence, l_start, l_len, l_sysid, l_pid, l_vfs = \
- struct.unpack('hhlllii', flock)
- elif sys.platform == "linux2":
- l_type, l_whence, l_start, l_len, l_pid, l_sysid = \
- struct.unpack('hhllhh', flock)
- else:
- l_type, l_whence, l_start, l_len, l_sysid, l_pid = \
- struct.unpack('hhllhh', flock)
-
- if l_type != fcntl.F_UNLCK:
- if l_type == fcntl.F_RDLCK:
- return 'r', l_len, l_start, l_whence, l_pid
- else:
- return 'w', l_len, l_start, l_whence, l_pid
-
-def open(name, mode='r', bufsize=-1):
- """Public routine to open a file as a posixfile object."""
- return _posixfile_().open(name, mode, bufsize)
-
-def fileopen(file):
- """Public routine to get a posixfile object from a Python file object."""
- return _posixfile_().fileopen(file)
-
-#
-# Constants
-#
-SEEK_SET = 0
-SEEK_CUR = 1
-SEEK_END = 2
-
-#
-# End of posixfile.py
-#
Modified: python/branches/p3yk/Lib/test/test_sundry.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_sundry.py (original)
+++ python/branches/p3yk/Lib/test/test_sundry.py Sat Jun 2 09:51:44 2007
@@ -4,9 +4,6 @@
import warnings
with guard_warnings_filter():
- warnings.filterwarnings('ignore', r".*posixfile",
- DeprecationWarning)
-
from test.test_support import verbose
import BaseHTTPServer
@@ -41,7 +38,6 @@
import pdb
import pipes
#import poplib
- import posixfile
import pstats
import py_compile
import pydoc
Modified: python/branches/p3yk/Misc/cheatsheet
==============================================================================
--- python/branches/p3yk/Misc/cheatsheet (original)
+++ python/branches/p3yk/Misc/cheatsheet Sat Jun 2 09:51:44 2007
@@ -1845,7 +1845,6 @@
dumbdbm A dumb and slow but simple dbm clone.
[DEL:dump:DEL] [DEL:Print python code that reconstructs a variable.:DEL]
email Comprehensive support for internet email.
-exceptions Class based built-in exception hierarchy.
filecmp File comparison.
fileinput Helper class to quickly write a loop over all standard input
files.
@@ -1860,7 +1859,6 @@
www.pauahtun.org/pub/getargspy.zip
getpass Utilities to get a password and/or the current user name.
glob filename globbing.
-gopherlib Gopher protocol client interface.
[DEL:grep:DEL] [DEL:'grep' utilities.:DEL]
gzip Read & write gzipped files.
heapq Priority queue implemented using lists organized as heaps.
@@ -1875,7 +1873,6 @@
imputil Privides a way of writing customised import hooks.
inspect Tool for probing live Python objects.
keyword List of Python keywords.
-knee A Python re-implementation of hierarchical module import.
linecache Cache lines from files.
linuxaudiodev Lunix /dev/audio support.
locale Support for number formatting using the current locale
@@ -1888,8 +1885,6 @@
mhlib MH (mailbox) interface.
mimetools Various tools used by MIME-reading or MIME-writing programs.
mimetypes Guess the MIME type of a file.
-MimeWriter Generic MIME writer.
-mimify Mimification and unmimification of mail messages.
mmap Interface to memory-mapped files - they behave like mutable
strings./font>
multifile Class to make multi-file messages easier to handle.
@@ -1908,7 +1903,6 @@
pipes Conversion pipeline templates.
pkgunil Utilities for working with Python packages.
poplib A POP3 client class. Based on the J. Myers POP3 draft.
-posixfile Extended (posix) file operations.
posixpath Common operations on POSIX pathnames.
pprint Support to pretty-print lists, tuples, & dictionaries
recursively.
@@ -1921,7 +1915,6 @@
pyclbr Parse a Python file and retrieve classes and methods.
Queue A multi-producer, multi-consumer queue.
quopri Conversions to/from quoted-printable transport encoding.
-rand Don't use unless you want compatibility with C's rand().
random Random variable generators
re Regular Expressions.
repr Redo repr() but with limits on most sizes.
@@ -1930,7 +1923,6 @@
rlcompleter Word completion for GNU readline 2.0.
robotparser Parse robots.txt files, useful for web spiders.
sched A generally useful event scheduler class.
-sets Module for a set datatype.
sgmllib A parser for SGML.
shelve Manage shelves of pickled objects.
shlex Lexical analyzer class for simple shell-like syntaxes.
@@ -1942,7 +1934,6 @@
sndhdr Several routines that help recognizing sound.
SocketServer Generic socket server classes.
stat Constants and functions for interpreting stat/lstat struct.
-statcache Maintain a cache of file stats.
statvfs Constants for interpreting statvfs struct as returned by
os.statvfs()and os.fstatvfs() (if they exist).
string A collection of string operations.
More information about the Python-3000-checkins
mailing list