Commit 2a104988 authored by Jeffrey Shell's avatar Jeffrey Shell

unique values listing now won't return empty strings

parent 181ed4ff
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
__doc__='''Simple column indexes __doc__='''Simple column indexes
$Id: Index.py,v 1.15 1998/10/13 21:07:17 jeffrey Exp $''' $Id: Index.py,v 1.16 1998/12/14 16:32:55 jeffrey Exp $'''
__version__='$Revision: 1.15 $'[11:-2] __version__='$Revision: 1.16 $'[11:-2]
from Globals import Persistent from Globals import Persistent
from BTree import BTree from BTree import BTree
...@@ -21,6 +21,15 @@ from Missing import MV ...@@ -21,6 +21,15 @@ from Missing import MV
import string import string
ListType=type([]) ListType=type([])
StringType=type('s')
def nonEmpty(s):
"returns true if a non-empty string or any other (nonstring) type"
if type(s) is StringType:
if s: return 1
else: return 0
else:
return 1
class Index(Persistent): class Index(Persistent):
"""Index object interface""" """Index object interface"""
...@@ -63,11 +72,14 @@ class Index(Persistent): ...@@ -63,11 +72,14 @@ class Index(Persistent):
name = self.id name = self.id
elif name != self.id: elif name != self.id:
return [] return []
if not withLengths: return tuple(self._index.keys()) if not withLengths: return tuple(
filter(nonEmpty,self._index.keys())
)
else: else:
rl=[] rl=[]
for i in self._index.keys(): for i in self._index.keys():
rl.append((i, len(self._index[i]))) if not nonEmpty(i): continue
else: rl.append((i, len(self._index[i])))
return tuple(rl) return tuple(rl)
def clear(self): def clear(self):
...@@ -206,6 +218,9 @@ class Index(Persistent): ...@@ -206,6 +218,9 @@ class Index(Persistent):
############################################################################## ##############################################################################
# #
# $Log: Index.py,v $ # $Log: Index.py,v $
# Revision 1.16 1998/12/14 16:32:55 jeffrey
# unique values listing now won't return empty strings
#
# Revision 1.15 1998/10/13 21:07:17 jeffrey # Revision 1.15 1998/10/13 21:07:17 jeffrey
# added dpUniqueValues and dpHasUniqueValuesFor methods # added dpUniqueValues and dpHasUniqueValuesFor methods
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment