[Python-checkins] CVS: python/dist/src/Lib Cookie.py,1.8.4.1,1.8.4.2 cmd.py,1.23,1.23.4.1 dospath.py,1.22,1.22.6.1 dumbdbm.py,1.10.6.1,1.10.6.2 imaplib.py,1.27.6.1,1.27.6.2 ntpath.py,1.34.6.1,1.34.6.2 nturl2path.py,1.10,1.10.6.1 pipes.py,1.8.6.1,1.8.6.2 repr.py,1.9,1.9.6.1 sgmllib.py,1.30.4.3,1.30.4.4 site.py,1.26.4.2,1.26.4.3 sre_compile.py,1.37.4.1,1.37.4.2 string.py,1.59,1.59.6.1 tokenize.py,1.22.4.2,1.22.4.3 webbrowser.py,1.18,1.18.4.1 zipfile.py,1.13.4.1,1.13.4.2
Tim Peters
tim_one@users.sourceforge.net
2001年7月20日 23:07:15 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv27169/descr/dist/src/Lib
Modified Files:
Tag: descr-branch
Cookie.py cmd.py dospath.py dumbdbm.py imaplib.py ntpath.py
nturl2path.py pipes.py repr.py sgmllib.py site.py
sre_compile.py string.py tokenize.py webbrowser.py zipfile.py
Log Message:
Merge of trunk delta date2001-07-17b to date2001-07-21. See PLAN.txt.
Index: Cookie.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/Cookie.py,v
retrieving revision 1.8.4.1
retrieving revision 1.8.4.2
diff -C2 -r1.8.4.1 -r1.8.4.2
*** Cookie.py 2001年07月07日 22:55:27 1.8.4.1
--- Cookie.py 2001年07月21日 06:07:12 1.8.4.2
***************
*** 250,254 ****
# _Translator hash-table for fast quoting
#
! _LegalChars = string.letters + string.digits + "!#$%&'*+-.^_`|~"
_Translator = {
'000円' : '\000円', '001円' : '\001円', '002円' : '\002円',
--- 250,254 ----
# _Translator hash-table for fast quoting
#
! _LegalChars = string.ascii_letters + string.digits + "!#$%&'*+-.^_`|~"
_Translator = {
'000円' : '\000円', '001円' : '\001円', '002円' : '\002円',
Index: cmd.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v
retrieving revision 1.23
retrieving revision 1.23.4.1
diff -C2 -r1.23 -r1.23.4.1
*** cmd.py 2001年03月22日 21:59:20 1.23
--- cmd.py 2001年07月21日 06:07:12 1.23.4.1
***************
*** 41,45 ****
PROMPT = '(Cmd) '
! IDENTCHARS = string.letters + string.digits + '_'
class Cmd:
--- 41,45 ----
PROMPT = '(Cmd) '
! IDENTCHARS = string.ascii_letters + string.digits + '_'
class Cmd:
Index: dospath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dospath.py,v
retrieving revision 1.22
retrieving revision 1.22.6.1
diff -C2 -r1.22 -r1.22.6.1
*** dospath.py 2001年01月20日 23:34:12 1.22
--- dospath.py 2001年07月21日 06:07:12 1.22.6.1
***************
*** 242,246 ****
return path
import string
! varchars = string.letters + string.digits + '_-'
res = ''
index = 0
--- 242,246 ----
return path
import string
! varchars = string.ascii_letters + string.digits + "_-"
res = ''
index = 0
Index: dumbdbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dumbdbm.py,v
retrieving revision 1.10.6.1
retrieving revision 1.10.6.2
diff -C2 -r1.10.6.1 -r1.10.6.2
*** dumbdbm.py 2001年07月07日 22:55:27 1.10.6.1
--- dumbdbm.py 2001年07月21日 06:07:12 1.10.6.2
***************
*** 22,26 ****
"""
! _os = __import__('os')
import __builtin__
--- 22,26 ----
"""
! import os as _os
import __builtin__
Index: imaplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v
retrieving revision 1.27.6.1
retrieving revision 1.27.6.2
diff -C2 -r1.27.6.1 -r1.27.6.2
*** imaplib.py 2001年07月07日 22:55:27 1.27.6.1
--- imaplib.py 2001年07月21日 06:07:12 1.27.6.2
***************
*** 15,20 ****
# Authentication code contributed by Donn Cave <donn@u.washington.edu> June 1998.
# String method conversion by ESR, February 2001.
! __version__ = "2.40"
import binascii, re, socket, time, random, sys
--- 15,21 ----
# Authentication code contributed by Donn Cave <donn@u.washington.edu> June 1998.
# String method conversion by ESR, February 2001.
+ # GET/SETACL contributed by Anthony Baxter <anthony@interlink.com.au> April 2001.
! __version__ = "2.47"
import binascii, re, socket, time, random, sys
***************
*** 45,52 ****
--- 46,55 ----
'EXPUNGE': ('SELECTED',),
'FETCH': ('SELECTED',),
+ 'GETACL': ('AUTH', 'SELECTED'),
'LIST': ('AUTH', 'SELECTED'),
'LOGIN': ('NONAUTH',),
'LOGOUT': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'),
'LSUB': ('AUTH', 'SELECTED'),
+ 'NAMESPACE': ('AUTH', 'SELECTED'),
'NOOP': ('NONAUTH', 'AUTH', 'SELECTED', 'LOGOUT'),
'PARTIAL': ('SELECTED',),
***************
*** 54,57 ****
--- 57,62 ----
'SEARCH': ('SELECTED',),
'SELECT': ('AUTH', 'SELECTED'),
+ 'SETACL': ('AUTH', 'SELECTED'),
+ 'SORT': ('SELECTED',),
'STATUS': ('AUTH', 'SELECTED'),
'STORE': ('SELECTED',),
***************
*** 59,63 ****
'UID': ('SELECTED',),
'UNSUBSCRIBE': ('AUTH', 'SELECTED'),
- 'NAMESPACE': ('AUTH', 'SELECTED'),
}
--- 64,67 ----
***************
*** 156,159 ****
--- 160,164 ----
if __debug__:
if self.debug >= 1:
+ _mesg('imaplib version %s' % __version__)
_mesg('new IMAP4 connection, tag=%s' % self.tagpre)
***************
*** 188,201 ****
# Allow UPPERCASE variants of IMAP4 command methods.
if Commands.has_key(attr):
! return eval("self.%s" % attr.lower())
raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
! # Public methods
def open(self, host, port):
! """Setup 'self.sock' and 'self.file'."""
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
--- 193,209 ----
# Allow UPPERCASE variants of IMAP4 command methods.
if Commands.has_key(attr):
! return getattr(self, attr.lower())
raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
! # Overridable methods
def open(self, host, port):
! """Setup connection to remote server on "host:port".
! This connection will be used by the routines:
! read, readline, send, shutdown.
! """
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
***************
*** 203,206 ****
--- 211,247 ----
+ def read(self, size):
+ """Read 'size' bytes from remote."""
+ return self.file.read(size)
+
+
+ def readline(self):
+ """Read line from remote."""
+ return self.file.readline()
+
+
+ def send(self, data):
+ """Send data to remote."""
+ self.sock.send(data)
+
+
+ def shutdown(self):
+ """Close I/O established in "open"."""
+ self.file.close()
+ self.sock.close()
+
+
+ def socket(self):
+ """Return socket instance used to connect to IMAP4 server.
+
+ socket = <instance>.socket()
+ """
+ return self.sock
+
+
+
+ # Utility methods
+
+
def recent(self):
"""Return most recent 'RECENT' responses if any exist,
***************
*** 230,242 ****
- def socket(self):
- """Return socket instance used to connect to IMAP4 server.
-
- socket = <instance>.socket()
- """
- return self.sock
-
-
# IMAP4 commands
--- 271,275 ----
***************
*** 369,372 ****
--- 402,414 ----
+ def getacl(self, mailbox):
+ """Get the ACLs for a mailbox.
+
+ (typ, [data]) = <instance>.getacl(mailbox)
+ """
+ typ, dat = self._simple_command('GETACL', mailbox)
+ return self._untagged_response(typ, dat, 'ACL')
+
+
def list(self, directory='""', pattern='*'):
"""List mailbox names in directory matching pattern.
***************
*** 407,412 ****
try: typ, dat = self._simple_command('LOGOUT')
except: typ, dat = 'NO', ['%s: %s' % sys.exc_info()[:2]]
! self.file.close()
! self.sock.close()
if self.untagged_responses.has_key('BYE'):
return 'BYE', self.untagged_responses['BYE']
--- 449,453 ----
try: typ, dat = self._simple_command('LOGOUT')
except: typ, dat = 'NO', ['%s: %s' % sys.exc_info()[:2]]
! self.shutdown()
if self.untagged_responses.has_key('BYE'):
return 'BYE', self.untagged_responses['BYE']
***************
*** 426,429 ****
--- 467,480 ----
+ def namespace(self):
+ """ Returns IMAP namespaces ala rfc2342
+
+ (typ, [data, ...]) = <instance>.namespace()
+ """
+ name = 'NAMESPACE'
+ typ, dat = self._simple_command(name)
+ return self._untagged_response(typ, dat, name)
+
+
def noop(self):
"""Send NOOP command.
***************
*** 466,471 ****
name = 'SEARCH'
if charset:
! charset = 'CHARSET ' + charset
! typ, dat = apply(self._simple_command, (name, charset) + criteria)
return self._untagged_response(typ, dat, name)
--- 517,523 ----
name = 'SEARCH'
if charset:
! typ, dat = apply(self._simple_command, (name, 'CHARSET', charset) + criteria)
! else:
! typ, dat = apply(self._simple_command, (name,) + criteria)
return self._untagged_response(typ, dat, name)
***************
*** 501,504 ****
--- 553,578 ----
+ def setacl(self, mailbox, who, what):
+ """Set a mailbox acl.
+
+ (typ, [data]) = <instance>.create(mailbox, who, what)
+ """
+ return self._simple_command('SETACL', mailbox, who, what)
+
+
+ def sort(self, sort_criteria, charset, *search_criteria):
+ """IMAP4rev1 extension SORT command.
+
+ (typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)
+ """
+ name = 'SORT'
+ #if not name in self.capabilities: # Let the server decide!
+ # raise self.error('unimplemented extension command: %s' % name)
+ if (sort_criteria[0],sort_criteria[-1]) != ('(',')'):
+ sort_criteria = '(%s)' % sort_criteria
+ typ, dat = apply(self._simple_command, (name, sort_criteria, charset) + search_criteria)
+ return self._untagged_response(typ, dat, name)
+
+
def status(self, mailbox, names):
"""Request named status conditions for mailbox.
***************
*** 507,512 ****
"""
name = 'STATUS'
! if self.PROTOCOL_VERSION == 'IMAP4':
! raise self.error('%s unimplemented in IMAP4 (obtain IMAP4rev1 server, or re-code)' % name)
typ, dat = self._simple_command(name, mailbox, names)
return self._untagged_response(typ, dat, name)
--- 581,586 ----
"""
name = 'STATUS'
! #if self.PROTOCOL_VERSION == 'IMAP4': # Let the server decide!
! # raise self.error('%s unimplemented in IMAP4 (obtain IMAP4rev1 server, or re-code)' % name)
typ, dat = self._simple_command(name, mailbox, names)
return self._untagged_response(typ, dat, name)
***************
*** 548,553 ****
name = 'UID'
typ, dat = apply(self._simple_command, (name, command) + args)
! if command == 'SEARCH':
! name = 'SEARCH'
else:
name = 'FETCH'
--- 622,627 ----
name = 'UID'
typ, dat = apply(self._simple_command, (name, command) + args)
! if command in ('SEARCH', 'SORT'):
! name = command
else:
name = 'FETCH'
***************
*** 567,582 ****
notified by server in CAPABILITY response.
(typ, [data]) = <instance>.xatom(name, arg, ...)
"""
! if name[0] != 'X' or not name in self.capabilities:
! raise self.error('unknown extension command: %s' % name)
return apply(self._simple_command, (name,) + args)
- def namespace(self):
- """ Returns IMAP namespaces ala rfc2342
- """
- name = 'NAMESPACE'
- typ, dat = self._simple_command(name)
- return self._untagged_response(typ, dat, name)
--- 641,657 ----
notified by server in CAPABILITY response.
+ Assumes command is legal in current state.
+
(typ, [data]) = <instance>.xatom(name, arg, ...)
+
+ Returns response appropriate to extension command `name'.
"""
! name = name.upper()
! #if not name in self.capabilities: # Let the server decide!
! # raise self.error('unknown extension command: %s' % name)
! if not Commands.has_key(name):
! Commands[name] = (self.state,)
return apply(self._simple_command, (name,) + args)
***************
*** 641,646 ****
try:
! self.sock.send('%s%s' % (data, CRLF))
! except socket.error, val:
raise self.abort('socket error: %s' % val)
--- 716,721 ----
try:
! self.send('%s%s' % (data, CRLF))
! except (socket.error, OSError), val:
raise self.abort('socket error: %s' % val)
***************
*** 665,671 ****
try:
! self.sock.send(literal)
! self.sock.send(CRLF)
! except socket.error, val:
raise self.abort('socket error: %s' % val)
--- 740,746 ----
try:
! self.send(literal)
! self.send(CRLF)
! except (socket.error, OSError), val:
raise self.abort('socket error: %s' % val)
***************
*** 742,746 ****
if self.debug >= 4:
_mesg('read literal size %s' % size)
! data = self.file.read(size)
# Store response with literal as tuple
--- 817,821 ----
if self.debug >= 4:
_mesg('read literal size %s' % size)
! data = self.read(size)
# Store response with literal as tuple
***************
*** 790,794 ****
def _get_line(self):
! line = self.file.readline()
if not line:
raise self.abort('socket error: EOF')
--- 865,869 ----
def _get_line(self):
! line = self.readline()
if not line:
raise self.abort('socket error: EOF')
***************
*** 1024,1028 ****
t = '\n\t\t'
l = map(lambda x:'%s: "%s"' % (x[0], x[1][0] and '" "'.join(x[1]) or ''), l)
! _mesg('untagged responses dump:%s%s' % (t, j(l, t)))
_cmd_log = [] # Last `_cmd_log_len' interactions
--- 1099,1103 ----
t = '\n\t\t'
l = map(lambda x:'%s: "%s"' % (x[0], x[1][0] and '" "'.join(x[1]) or ''), l)
! _mesg('untagged responses dump:%s%s' % (t, t.join(l)))
_cmd_log = [] # Last `_cmd_log_len' interactions
***************
*** 1060,1064 ****
USER = getpass.getuser()
! PASSWD = getpass.getpass("IMAP password for %s on %s:" % (USER, host or "localhost"))
test_mesg = 'From: %s@localhost\nSubject: IMAP4 test\n\ndata...\n' % USER
--- 1135,1139 ----
USER = getpass.getuser()
! PASSWD = getpass.getpass("IMAP password for %s on %s: " % (USER, host or "localhost"))
test_mesg = 'From: %s@localhost\nSubject: IMAP4 test\n\ndata...\n' % USER
***************
*** 1074,1077 ****
--- 1149,1153 ----
('partial', ('1', 'RFC822', 1, 1024)),
('store', ('1', 'FLAGS', '(\Deleted)')),
+ ('namespace', ()),
('expunge', ()),
('recent', ()),
***************
*** 1091,1095 ****
def run(cmd, args):
_mesg('%s %s' % (cmd, args))
! typ, dat = apply(eval('M.%s' % cmd), args)
_mesg('%s => %s %s' % (cmd, typ, dat))
return dat
--- 1167,1171 ----
def run(cmd, args):
_mesg('%s %s' % (cmd, args))
! typ, dat = apply(getattr(M, cmd), args)
_mesg('%s => %s %s' % (cmd, typ, dat))
return dat
***************
*** 1098,1101 ****
--- 1174,1178 ----
M = IMAP4(host)
_mesg('PROTOCOL_VERSION = %s' % M.PROTOCOL_VERSION)
+ _mesg('CAPABILITIES = %s' % `M.capabilities`)
for cmd,args in test_seq1:
Index: ntpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v
retrieving revision 1.34.6.1
retrieving revision 1.34.6.2
diff -C2 -r1.34.6.1 -r1.34.6.2
*** ntpath.py 2001年07月07日 22:55:28 1.34.6.1
--- ntpath.py 2001年07月21日 06:07:12 1.34.6.2
***************
*** 43,52 ****
path = a
for b in p:
! if isabs(b):
! path = b
! elif path == '' or path[-1:] in '/\\:':
! path = path + b
! else:
! path = path + "\\" + b
return path
--- 43,62 ----
path = a
for b in p:
! # If path is a raw drive letter (e.g. "C:"), and b doesn't start
! # with a drive letter, path+b is correct, and regardless of whether
! # b is absolute on its own.
! if len(path) == 2 and path[-1] == ":" and splitdrive(b)[0] == "":
! pass
!
! # In any other case, if b is absolute it wipes out the path so far.
! elif isabs(b) or path == "":
! path = ""
!
! # Else make sure a separator appears between the pieces.
! elif path[-1:] not in "/\\":
! b = "\\" + b
!
! path += b
!
return path
***************
*** 325,329 ****
return path
import string
! varchars = string.letters + string.digits + '_-'
res = ''
index = 0
--- 335,339 ----
return path
import string
! varchars = string.ascii_letters + string.digits + '_-'
res = ''
index = 0
Index: nturl2path.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/nturl2path.py,v
retrieving revision 1.10
retrieving revision 1.10.6.1
diff -C2 -r1.10 -r1.10.6.1
*** nturl2path.py 2001年02月18日 03:30:53 1.10
--- nturl2path.py 2001年07月21日 06:07:12 1.10.6.1
***************
*** 22,26 ****
return urllib.unquote('\\'.join(components))
comp = url.split('|')
! if len(comp) != 2 or comp[0][-1] not in string.letters:
error = 'Bad URL: ' + url
raise IOError, error
--- 22,26 ----
return urllib.unquote('\\'.join(components))
comp = url.split('|')
! if len(comp) != 2 or comp[0][-1] not in string.ascii_letters:
error = 'Bad URL: ' + url
raise IOError, error
***************
*** 43,47 ****
"""
! import string, urllib
if not ':' in p:
# No drive specifier, just convert slashes and quote the name
--- 43,47 ----
"""
! import urllib
if not ':' in p:
# No drive specifier, just convert slashes and quote the name
Index: pipes.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pipes.py,v
retrieving revision 1.8.6.1
retrieving revision 1.8.6.2
diff -C2 -r1.8.6.1 -r1.8.6.2
*** pipes.py 2001年07月07日 22:55:28 1.8.6.1
--- pipes.py 2001年07月21日 06:07:12 1.8.6.2
***************
*** 4,9 ****
------------
! Suppose you have some data that you want to convert to another format
! (e.g. from GIF image format to PPM image format). Maybe the
conversion involves several steps (e.g. piping it through compress or
uuencode). Some of the conversion steps may require that their input
--- 4,9 ----
------------
! Suppose you have some data that you want to convert to another format,
! such as from GIF image format to PPM image format. Maybe the
conversion involves several steps (e.g. piping it through compress or
uuencode). Some of the conversion steps may require that their input
***************
*** 265,269 ****
# Reliably quote a string as a single argument for /bin/sh
! _safechars = string.letters + string.digits + '!@%_-+=:,./' # Safe unquoted
_funnychars = '"`$\\' # Unsafe inside "double quotes"
--- 265,269 ----
# Reliably quote a string as a single argument for /bin/sh
! _safechars = string.ascii_letters + string.digits + '!@%_-+=:,./' # Safe unquoted
_funnychars = '"`$\\' # Unsafe inside "double quotes"
Index: repr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/repr.py,v
retrieving revision 1.9
retrieving revision 1.9.6.1
diff -C2 -r1.9 -r1.9.6.1
*** repr.py 2001年02月15日 22:15:13 1.9
--- repr.py 2001年07月21日 06:07:12 1.9.6.1
***************
*** 63,67 ****
if n > self.maxdict: s = s + ', ...'
return '{' + s + '}'
! def repr_string(self, x, level):
s = `x[:self.maxstring]`
if len(s) > self.maxstring:
--- 63,67 ----
if n > self.maxdict: s = s + ', ...'
return '{' + s + '}'
! def repr_str(self, x, level):
s = `x[:self.maxstring]`
if len(s) > self.maxstring:
***************
*** 71,75 ****
s = s[:i] + '...' + s[len(s)-j:]
return s
! def repr_long_int(self, x, level):
s = `x` # XXX Hope this isn't too slow...
if len(s) > self.maxlong:
--- 71,75 ----
s = s[:i] + '...' + s[len(s)-j:]
return s
! def repr_long(self, x, level):
s = `x` # XXX Hope this isn't too slow...
if len(s) > self.maxlong:
Index: sgmllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v
retrieving revision 1.30.4.3
retrieving revision 1.30.4.4
diff -C2 -r1.30.4.3 -r1.30.4.4
*** sgmllib.py 2001年07月16日 21:39:41 1.30.4.3
--- sgmllib.py 2001年07月21日 06:07:12 1.30.4.4
***************
*** 66,76 ****
class SGMLParser:
- # Interface -- initialize and reset this instance
def __init__(self, verbose=0):
self.verbose = verbose
self.reset()
- # Interface -- reset this instance. Loses all unprocessed data
def reset(self):
self.rawdata = ''
self.stack = []
--- 66,76 ----
class SGMLParser:
def __init__(self, verbose=0):
+ """Initialize and reset this instance."""
self.verbose = verbose
self.reset()
def reset(self):
+ """Reset this instance. Loses all unprocessed data."""
self.rawdata = ''
self.stack = []
***************
*** 79,100 ****
self.literal = 0
- # For derived classes only -- enter literal mode (CDATA) till EOF
def setnomoretags(self):
self.nomoretags = self.literal = 1
- # For derived classes only -- enter literal mode (CDATA)
def setliteral(self, *args):
self.literal = 1
- # Interface -- feed some data to the parser. Call this as
- # often as you want, with as little or as much text as you
- # want (may include '\n'). (This just saves the text, all the
- # processing is done by goahead().)
def feed(self, data):
self.rawdata = self.rawdata + data
self.goahead(0)
- # Interface -- handle the remaining data
def close(self):
self.goahead(1)
--- 79,109 ----
self.literal = 0
def setnomoretags(self):
+ """Enter literal mode (CDATA) till EOF.
+
+ Intended for derived classes only.
+ """
self.nomoretags = self.literal = 1
def setliteral(self, *args):
+ """Enter literal mode (CDATA).
+
+ Intended for derived classes only.
+ """
self.literal = 1
def feed(self, data):
+ """Feed some data to the parser.
+
+ Call this as often as you want, with as little or as much text
+ as you want (may include '\n'). (This just saves the text,
+ all the processing is done by goahead().)
+ """
+
self.rawdata = self.rawdata + data
self.goahead(0)
def close(self):
+ """Handle the remaining data."""
self.goahead(1)
***************
*** 408,413 ****
print '*** Stack:', self.stack
- # Example -- handle character reference, no need to override
def handle_charref(self, name):
try:
n = int(name)
--- 417,422 ----
print '*** Stack:', self.stack
def handle_charref(self, name):
+ """Handle character reference, no need to override."""
try:
n = int(name)
***************
*** 424,429 ****
{'lt': '<', 'gt': '>', 'amp': '&', 'quot': '"', 'apos': '\''}
- # Example -- handle entity reference, no need to override
def handle_entityref(self, name):
table = self.entitydefs
if table.has_key(name):
--- 433,442 ----
{'lt': '<', 'gt': '>', 'amp': '&', 'quot': '"', 'apos': '\''}
def handle_entityref(self, name):
+ """Handle entity references.
+
+ There should be no need to override this method; it can be
+ tailored by setting up the self.entitydefs mapping appropriately.
+ """
table = self.entitydefs
if table.has_key(name):
Index: site.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v
retrieving revision 1.26.4.2
retrieving revision 1.26.4.3
diff -C2 -r1.26.4.2 -r1.26.4.3
*** site.py 2001年07月14日 07:47:34 1.26.4.2
--- site.py 2001年07月21日 06:07:12 1.26.4.3
***************
*** 78,82 ****
# only absolute pathnames, even if we're running from the build directory.
L = []
! dirs_in_sys_path = {}
for dir in sys.path:
# Filter out paths that don't exist, but leave in the empty string
--- 78,82 ----
# only absolute pathnames, even if we're running from the build directory.
L = []
! _dirs_in_sys_path = {}
for dir in sys.path:
# Filter out paths that don't exist, but leave in the empty string
***************
*** 85,91 ****
continue
dir, dircase = makepath(dir)
! if not dirs_in_sys_path.has_key(dircase):
L.append(dir)
! dirs_in_sys_path[dircase] = 1
sys.path[:] = L
del dir, L
--- 85,91 ----
continue
dir, dircase = makepath(dir)
! if not _dirs_in_sys_path.has_key(dircase):
L.append(dir)
! _dirs_in_sys_path[dircase] = 1
sys.path[:] = L
del dir, L
***************
*** 100,106 ****
del get_platform, s
def addsitedir(sitedir):
sitedir, sitedircase = makepath(sitedir)
! if not dirs_in_sys_path.has_key(sitedircase):
sys.path.append(sitedir) # Add path component
try:
--- 100,121 ----
del get_platform, s
+ def _init_pathinfo():
+ global _dirs_in_sys_path
+ _dirs_in_sys_path = d = {}
+ for dir in sys.path:
+ if dir and not os.path.isdir(dir):
+ continue
+ dir, dircase = makepath(dir)
+ d[dircase] = 1
+
def addsitedir(sitedir):
+ global _dirs_in_sys_path
+ if _dirs_in_sys_path is None:
+ _init_pathinfo()
+ reset = 1
+ else:
+ reset = 0
sitedir, sitedircase = makepath(sitedir)
! if not _dirs_in_sys_path.has_key(sitedircase):
sys.path.append(sitedir) # Add path component
try:
***************
*** 112,117 ****
--- 127,140 ----
if name[-4:] == endsep + "pth":
addpackage(sitedir, name)
+ if reset:
+ _dirs_in_sys_path = None
def addpackage(sitedir, name):
+ global _dirs_in_sys_path
+ if _dirs_in_sys_path is None:
+ _init_pathinfo()
+ reset = 1
+ else:
+ reset = 0
fullname = os.path.join(sitedir, name)
try:
***************
*** 131,137 ****
dir = dir[:-1]
dir, dircase = makepath(sitedir, dir)
! if not dirs_in_sys_path.has_key(dircase) and os.path.exists(dir):
sys.path.append(dir)
! dirs_in_sys_path[dircase] = 1
prefixes = [sys.prefix]
--- 154,162 ----
dir = dir[:-1]
dir, dircase = makepath(sitedir, dir)
! if not _dirs_in_sys_path.has_key(dircase) and os.path.exists(dir):
sys.path.append(dir)
! _dirs_in_sys_path[dircase] = 1
! if reset:
! _dirs_in_sys_path = None
prefixes = [sys.prefix]
***************
*** 151,156 ****
if os.path.isdir(sitedir):
addsitedir(sitedir)
- del dirs_in_sys_path
# Define new built-ins 'quit' and 'exit'.
--- 176,182 ----
if os.path.isdir(sitedir):
addsitedir(sitedir)
+
+ _dirs_in_sys_path = None
# Define new built-ins 'quit' and 'exit'.
Index: sre_compile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v
retrieving revision 1.37.4.1
retrieving revision 1.37.4.2
diff -C2 -r1.37.4.1 -r1.37.4.2
*** sre_compile.py 2001年07月07日 22:55:28 1.37.4.1
--- sre_compile.py 2001年07月21日 06:07:12 1.37.4.2
***************
*** 9,13 ****
#
! import _sre
from sre_constants import *
--- 9,13 ----
#
! import _sre,sys
from sre_constants import *
***************
*** 282,288 ****
assert MAXCODE == 65535
for i in range(128):
! header.append(mapping[2*i]+256*mapping[2*i+1])
data[0:0] = header
! return [(BIGCHARSET, data)]
def _simple(av):
--- 282,291 ----
assert MAXCODE == 65535
for i in range(128):
! if sys.byteorder == 'big':
! header.append(256*mapping[2*i]+mapping[2*i+1])
! else:
! header.append(mapping[2*i]+256*mapping[2*i+1])
data[0:0] = header
! return [(BIGCHARSET, data)]
def _simple(av):
Index: string.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v
retrieving revision 1.59
retrieving revision 1.59.6.1
diff -C2 -r1.59 -r1.59.6.1
*** string.py 2001年02月18日 03:30:53 1.59
--- string.py 2001年07月21日 06:07:12 1.59.6.1
***************
*** 25,28 ****
--- 25,31 ----
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
letters = lowercase + uppercase
+ ascii_lowercase = lowercase
+ ascii_uppercase = uppercase
+ ascii_letters = ascii_lowercase + ascii_uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'
Index: tokenize.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tokenize.py,v
retrieving revision 1.22.4.2
retrieving revision 1.22.4.3
diff -C2 -r1.22.4.2 -r1.22.4.3
*** tokenize.py 2001年07月16日 21:39:41 1.22.4.2
--- tokenize.py 2001年07月21日 06:07:12 1.22.4.3
***************
*** 134,138 ****
def generate_tokens(readline):
lnum = parenlev = continued = 0
! namechars, numchars = string.letters + '_', string.digits
contstr, needcont = '', 0
contline = None
--- 134,138 ----
def generate_tokens(readline):
lnum = parenlev = continued = 0
! namechars, numchars = string.ascii_letters + '_', '0123456789'
contstr, needcont = '', 0
contline = None
Index: webbrowser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/webbrowser.py,v
retrieving revision 1.18
retrieving revision 1.18.4.1
diff -C2 -r1.18 -r1.18.4.1
*** webbrowser.py 2001年04月12日 22:07:27 1.18
--- webbrowser.py 2001年07月21日 06:07:12 1.18.4.1
***************
*** 43,47 ****
get().open(url, new, autoraise)
! def open_new(url): # Marked deprecated. May be removed in 2.1.
get().open(url, 1)
--- 43,47 ----
get().open(url, new, autoraise)
! def open_new(url):
get().open(url, 1)
***************
*** 77,87 ****
ret
- #
- # Everything after this point initializes _browsers and _tryorder,
- # then disappears. Some class definitions and instances remain
- # live through these globals, but only the minimum set needed to
- # support the user's platform.
- #
#
# Platform support for Unix
--- 77,227 ----
ret
+ def _iscommand(cmd):
+ """Return true if cmd can be found on the executable search path."""
+ path = os.environ.get("PATH")
+ if not path:
+ return 0
+ for d in path.split(os.pathsep):
+ exe = os.path.join(d, cmd)
+ if os.path.isfile(exe):
+ return 1
+ return 0
+
+
+ PROCESS_CREATION_DELAY = 4
+
+
+ class GenericBrowser:
+ def __init__(self, cmd):
+ self.name, self.args = cmd.split(None, 1)
+ self.basename = os.path.basename(self.name)
+
+ def open(self, url, new=0, autoraise=1):
+ command = "%s %s" % (self.name, self.args)
+ os.system(command % url)
+
+ def open_new(self, url):
+ self.open(url)
+
+
+ class Netscape:
+ "Launcher class for Netscape browsers."
+ def __init__(self, name):
+ self.name = name
+ self.basename = os.path.basename(name)
+
+ def _remote(self, action, autoraise):
+ raise_opt = ("-noraise", "-raise")[autoraise]
+ cmd = "%s %s -remote '%s' >/dev/null 2>&1" % (self.name,
+ raise_opt,
+ action)
+ rc = os.system(cmd)
+ if rc:
+ import time
+ os.system("%s &" % self.name)
+ time.sleep(PROCESS_CREATION_DELAY)
+ rc = os.system(cmd)
+ return not rc
+
+ def open(self, url, new=0, autoraise=1):
+ if new:
+ self._remote("openURL(%s, new-window)"%url, autoraise)
+ else:
+ self._remote("openURL(%s)" % url, autoraise)
+
+ def open_new(self, url):
+ self.open(url, 1)
+
+
+ class Konqueror:
+ """Controller for the KDE File Manager (kfm, or Konqueror).
+
+ See http://developer.kde.org/documentation/other/kfmclient.html
+ for more information on the Konqueror remote-control interface.
+
+ """
+ def __init__(self):
+ if _iscommand("konqueror"):
+ self.name = self.basename = "konqueror"
+ else:
+ self.name = self.basename = "kfm"
+
+ def _remote(self, action):
+ cmd = "kfmclient %s >/dev/null 2>&1" % action
+ rc = os.system(cmd)
+ if rc:
+ import time
+ if self.basename == "konqueror":
+ os.system(self.name + " --silent &")
+ else:
+ os.system(self.name + " -d &")
+ time.sleep(PROCESS_CREATION_DELAY)
+ rc = os.system(cmd)
+ return not rc
+
+ def open(self, url, new=1, autoraise=1):
+ # XXX Currently I know no way to prevent KFM from
+ # opening a new win.
+ self._remote("openURL %s" % url)
+
+ open_new = open
+
+
+ class Grail:
+ # There should be a way to maintain a connection to Grail, but the
+ # Grail remote control protocol doesn't really allow that at this
+ # point. It probably neverwill!
+ def _find_grail_rc(self):
+ import glob
+ import pwd
+ import socket
+ import tempfile
+ tempdir = os.path.join(tempfile.gettempdir(),
+ ".grail-unix")
+ user = pwd.getpwuid(_os.getuid())[0]
+ filename = os.path.join(tempdir, user + "-*")
+ maybes = glob.glob(filename)
+ if not maybes:
+ return None
+ s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ for fn in maybes:
+ # need to PING each one until we find one that's live
+ try:
+ s.connect(fn)
+ except socket.error:
+ # no good; attempt to clean it out, but don't fail:
+ try:
+ os.unlink(fn)
+ except IOError:
+ pass
+ else:
+ return s
+
+ def _remote(self, action):
+ s = self._find_grail_rc()
+ if not s:
+ return 0
+ s.send(action)
+ s.close()
+ return 1
+
+ def open(self, url, new=0, autoraise=1):
+ if new:
+ self._remote("LOADNEW " + url)
+ else:
+ self._remote("LOAD " + url)
+
+ def open_new(self, url):
+ self.open(url, 1)
+
+
+ class WindowsDefault:
+ def open(self, url, new=0, autoraise=1):
+ os.startfile(url)
+
+ def open_new(self, url):
+ self.open(url)
+
#
# Platform support for Unix
***************
*** 93,122 ****
# an xterm.
if os.environ.get("TERM") or os.environ.get("DISPLAY"):
- PROCESS_CREATION_DELAY = 4
_tryorder = ("mozilla","netscape","kfm","grail","links","lynx","w3m")
- def _iscommand(cmd):
- """Return true if cmd can be found on the executable search path."""
- path = os.environ.get("PATH")
- if not path:
- return 0
- for d in path.split(os.pathsep):
- exe = os.path.join(d, cmd)
- if os.path.isfile(exe):
- return 1
- return 0
-
- class GenericBrowser:
- def __init__(self, cmd):
- self.name, self.args = cmd.split(None, 1)
- self.basename = os.path.basename(self.name)
-
- def open(self, url, new=0, autoraise=1):
- command = "%s %s" % (self.name, self.args)
- os.system(command % url)
-
- def open_new(self, url): # Deprecated. May be removed in 2.1.
- self.open(url)
-
# Easy cases first -- register console browsers if we have them.
if os.environ.get("TERM"):
--- 233,238 ----
***************
*** 135,167 ****
# First, the Netscape series
if _iscommand("netscape") or _iscommand("mozilla"):
- class Netscape:
- "Launcher class for Netscape browsers."
- def __init__(self, name):
- self.name = name
- self.basename = os.path.basename(name)
-
- def _remote(self, action, autoraise):
- raise_opt = ("-noraise", "-raise")[autoraise]
- cmd = "%s %s -remote '%s' >/dev/null 2>&1" % (self.name,
- raise_opt,
- action)
- rc = os.system(cmd)
- if rc:
- import time
- os.system("%s &" % self.name)
- time.sleep(PROCESS_CREATION_DELAY)
- rc = os.system(cmd)
- return not rc
-
- def open(self, url, new=0, autoraise=1):
- if new:
- self._remote("openURL(%s, new-window)"%url, autoraise)
- else:
- self._remote("openURL(%s)" % url, autoraise)
-
- # Deprecated. May be removed in 2.1.
- def open_new(self, url):
- self.open(url, 1)
-
if _iscommand("mozilla"):
register("mozilla", None, Netscape("mozilla"))
--- 251,254 ----
***************
*** 175,266 ****
# Konqueror/kfm, the KDE browser.
if _iscommand("kfm") or _iscommand("konqueror"):
- class Konqueror:
- """Controller for the KDE File Manager (kfm, or Konqueror).
-
- See http://developer.kde.org/documentation/other/kfmclient.html
- for more information on the Konqueror remote-control interface.
-
- """
- def __init__(self):
- if _iscommand("konqueror"):
- self.name = self.basename = "konqueror"
- else:
- self.name = self.basename = "kfm"
-
- def _remote(self, action):
- cmd = "kfmclient %s >/dev/null 2>&1" % action
- rc = os.system(cmd)
- if rc:
- import time
- if self.basename == "konqueror":
- os.system(self.name + " --silent &")
- else:
- os.system(self.name + " -d &")
- time.sleep(PROCESS_CREATION_DELAY)
- rc = os.system(cmd)
- return not rc
-
- def open(self, url, new=1, autoraise=1):
- # XXX Currently I know no way to prevent KFM from
- # opening a new win.
- self._remote("openURL %s" % url)
-
- # Deprecated. May be removed in 2.1.
- open_new = open
-
register("kfm", Konqueror, Konqueror())
# Grail, the Python browser.
if _iscommand("grail"):
- class Grail:
- # There should be a way to maintain a connection to
- # Grail, but the Grail remote control protocol doesn't
- # really allow that at this point. It probably neverwill!
- def _find_grail_rc(self):
- import glob
- import pwd
- import socket
- import tempfile
- tempdir = os.path.join(tempfile.gettempdir(),
- ".grail-unix")
- user = pwd.getpwuid(_os.getuid())[0]
- filename = os.path.join(tempdir, user + "-*")
- maybes = glob.glob(filename)
- if not maybes:
- return None
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- for fn in maybes:
- # need to PING each one until we find one that's live
- try:
- s.connect(fn)
- except socket.error:
- # no good; attempt to clean it out, but don't fail:
- try:
- os.unlink(fn)
- except IOError:
- pass
- else:
- return s
-
- def _remote(self, action):
- s = self._find_grail_rc()
- if not s:
- return 0
- s.send(action)
- s.close()
- return 1
-
- def open(self, url, new=0, autoraise=1):
- if new:
- self._remote("LOADNEW " + url)
- else:
- self._remote("LOAD " + url)
-
- # Deprecated. May be removed in 2.1.
- def open_new(self, url):
- self.open(url, 1)
-
register("grail", Grail, None)
#
# Platform support for Windows
--- 262,280 ----
# Konqueror/kfm, the KDE browser.
if _iscommand("kfm") or _iscommand("konqueror"):
register("kfm", Konqueror, Konqueror())
# Grail, the Python browser.
if _iscommand("grail"):
register("grail", Grail, None)
+
+ class InternetConfig:
+ def open(self, url, new=0, autoraise=1):
+ ic.launchurl(url)
+
+ def open_new(self, url):
+ self.open(url)
+
+
#
# Platform support for Windows
***************
*** 269,280 ****
if sys.platform[:3] == "win":
_tryorder = ("netscape", "windows-default")
-
- class WindowsDefault:
- def open(self, url, new=0, autoraise=1):
- os.startfile(url)
-
- def open_new(self, url): # Deprecated. May be removed in 2.1.
- self.open(url)
-
register("windows-default", WindowsDefault)
--- 283,286 ----
***************
*** 288,298 ****
pass
else:
- class InternetConfig:
- def open(self, url, new=0, autoraise=1):
- ic.launchurl(url)
-
- def open_new(self, url): # Deprecated. May be removed in 2.1.
- self.open(url)
-
# internet-config is the only supported controller on MacOS,
# so don't mess with the default!
--- 294,297 ----
***************
*** 307,316 ****
# browser referenced by this value, before calling open().
_tryorder = os.environ["BROWSER"].split(":")
- else:
- # Optimization: filter out alternatives that aren't available, so we can
- # avoid has_key() tests at runtime. (This may also allow some unused
- # classes and class-instance storage to be garbage-collected.)
- _tryorder = filter(lambda x: _browsers.has_key(x.lower())
- or x.find("%s") > -1, _tryorder)
! # end
--- 306,316 ----
# browser referenced by this value, before calling open().
_tryorder = os.environ["BROWSER"].split(":")
! for cmd in _tryorder:
! if not _browsers.has_key(cmd.lower()):
! if _iscommand(cmd.lower()):
! register(cmd.lower(), None, GenericBrowser("%s %%s" % cmd.lower()))
!
! _tryorder = filter(lambda x: _browsers.has_key(x.lower())
! or x.find("%s") > -1, _tryorder)
! # what to do if _tryorder is now empty?
Index: zipfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v
retrieving revision 1.13.4.1
retrieving revision 1.13.4.2
diff -C2 -r1.13.4.1 -r1.13.4.2
*** zipfile.py 2001年07月07日 22:55:28 1.13.4.1
--- zipfile.py 2001年07月21日 06:07:12 1.13.4.2
***************
*** 90,94 ****
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)):
! self.filename = filename # Name of the file in the archive
self.date_time = date_time # year, month, day, hour, min, sec
# Standard values:
--- 90,94 ----
def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)):
! self.filename = _normpath(filename) # Name of the file in the archive
self.date_time = date_time # year, month, day, hour, min, sec
# Standard values:
***************
*** 129,132 ****
--- 129,143 ----
len(self.filename), len(self.extra))
return header + self.filename + self.extra
+
+
+ # This is used to ensure paths in generated ZIP files always use
+ # forward slashes as the directory separator, as required by the
+ # ZIP format specification.
+ if os.sep != "/":
+ def _normpath(path):
+ return path.replace(os.sep, "/")
+ else:
+ def _normpath(path):
+ return path