[Zope-Checkins] CVS: Zope27/lib/python/SearchIndex - UnIndex.py:1.30.76.1
Fred L. Drake, Jr.
fdrake@acm.org
Tue, 20 Aug 2002 16:34:45 -0400
Update of /cvs-repository/Zope27/lib/python/SearchIndex
In directory cvs.zope.org:/tmp/cvs-serv11371/SearchIndex
Modified Files:
Tag: Zope-2_7-development-branch
UnIndex.py
Log Message:
Remove unnecessary aliasing. Python 2.3 issues a SyntaxWarning when binding
to the name None. Switch to using isinstance() in affected locations.
=== Zope27/lib/python/SearchIndex/UnIndex.py 1.30 => 1.30.76.1 ===
--- Zope27/lib/python/SearchIndex/UnIndex.py:1.30 Wed Nov 28 10:51:11 2001
+++ Zope27/lib/python/SearchIndex/UnIndex.py Tue Aug 20 16:34:15 2002
@@ -21,7 +21,6 @@
import IOBTree
import string
from zLOG import LOG, ERROR
-from types import StringType, ListType, IntType, TupleType
from BTrees.OOBTree import OOBTree, OOSet
from BTrees.IOBTree import IOBTree
@@ -91,12 +90,9 @@
_index=self._index
self._index=OOBTree()
- def convertSet(s,
- IITreeSet=IITreeSet, IntType=type(0),
- type=type, len=len,
- doneTypes = (IntType, IITreeSet)):
+ def convertSet(s, doneTypes=(int, IITreeSet)):
- if type(s) in doneTypes: return s
+ if isinstance(s, doneTypes): return s
if len(s) == 1:
try: return s[0] # convert to int
@@ -130,7 +126,7 @@
histogram = {}
for item in self._index.items():
- if type(item) is IntType:
+ if isinstance(items, int):
entry = 1 # "set" length is 1
else:
key, value = item
@@ -254,7 +250,7 @@
LOG('UnIndex', ERROR, 'Attempt to unindex nonexistent document'
' with id %s' % documentId)
- def _apply_index(self, request, cid='', type=type, None=None):
+ def _apply_index(self, request, cid=''):
"""Apply the index to query parameters given in the request arg.
The request argument should be a mapping object.
@@ -301,7 +297,7 @@
else:
return None
- if type(keys) not in (ListType, TupleType):
+ if not isinstance(keys, (list, tuple)):
if keys == '':
return None
else:
@@ -327,18 +323,18 @@
setlist = index.items(lo)
for k, set in setlist:
- if type(set) is IntType:
+ if isinstance(set, int):
set = IISet((set,))
r = union(r, set)
else: # not a range search
for key in keys:
set=index.get(key, None)
if set is not None:
- if type(set) is IntType:
+ if isinstance(set, int):
set = IISet((set,))
r = union(r, set)
- if type(r) is IntType: r=IISet((r,))
+ if isinstance(r, int): r=IISet((r,))
if r is None:
return IISet(), (id,)
else:
@@ -370,7 +366,7 @@
rl=[]
for i in self._index.keys():
set = self._index[i]
- if type(set) is IntType:
+ if isinstance(set, int):
l = 1
else:
l = len(set)
@@ -383,7 +379,7 @@
def items(self):
items = []
for k,v in self._index.items():
- if type(v) is IntType:
+ if isinstance(v, int):
v = IISet((v,))
items.append((k, v))
return items