Re: search is buggy in 1.2.6, remains buggy in 1.2.6.1
Peter Schulte-Stracke <mail-OvSX7JRiA6TkXZrADh/[email protected]>
| Newsgroups | gmane.comp.gnome.apps.pybliographer |
|---|---|
| Message-ID | <1108485528l.5080l.0l@britten> |
I. I enclose a patch for the aforementioned problem; however, I would like to have someone look into it before I make a new release, for obvious reasons. In the top directory of the source tree, run " patch -p1 < changes2.diff" II. Now that I try, searching for "any field" fails in Pyblio.Search, and not surprisingly, as it reads: if field.match (self.__test) is not None: Shouldn't this be the other way round? if self.__test.match (field) is not None: I'm puzzled, wondering whether I'm missing something. Regards, Peter
changes2.diff
(text/x-patch, 2.2 KB)
--- orig/Pyblio/Iterator.py
+++ mod/Pyblio/Iterator.py
@@ -22,6 +22,8 @@
class Iterator:
+ base = None
+
def iterator (self):
''' loop method, so that we can for example call a method by
passing indifferently a database or a database iterator...
@@ -50,8 +52,9 @@
''' This class defines a database iterator '''
def __init__ (self, database):
- self.keys = database.keys ()
- self.database = database
+ self.keys = database.keys ()
+ self.base = database
+ self.database = database
self.count = 0
return
--- orig/Pyblio/Selection.py
+++ mod/Pyblio/Selection.py
@@ -28,6 +28,7 @@
def __init__ (self, search, iterator):
self.search = search
self.iter = iterator
+ self.base = iterator.base
return
def __iter__ (self):
@@ -71,15 +72,15 @@
def __init__ (self, sort, iterator):
# compute asap
- self.keys = sort.sort (iterator)
- self.data = iterator.database or list(iterator)
+ self.data = sort.sort (iterator)
+ self.base = iterator.base
self.count = 0
return
def __iter__ (self):
self.count = 0
- for i in self.keys:
- yield self.data[i]
+ for i in self.data:
+ yield i
self.count += 1
raise StopIteration
@@ -89,10 +90,9 @@
def next (self):
try:
- ret = self.data [self.keys [self.count]]
+ ret = self.data [self.count]
except IndexError:
return None
-
self.count = self.count + 1
return ret
--- orig/Pyblio/Sort.py
+++ mod/Pyblio/Sort.py
@@ -36,14 +36,16 @@
def sort (self, iterator):
''' Returns a list of keys sorted according to the current
sort settings '''
-
+
+ self.base = iterator.base
+
S = []
extractors = [f.get_extractor() for f in self.fields]
for e in iterator:
s = []
for f in extractors:
s.extend (f (e))
- s.append (e.key)
+ s.append (e)
S.append (s)
S.sort ()
result = [x [-1] for x in S]