Commits

coady  committed 48c4784

PyLucene 3.2 deprecated and previous deprecations removed.

  • Participants
  • Parent commits 44dc9ea

Comments (0)

Files changed (6)

File lupyne/engine/__init__.py

 from .indexers import TokenFilter, Analyzer, IndexSearcher, MultiSearcher, IndexWriter, Indexer, ParallelIndexer
 from .spatial import PointField, PolygonField
 
-assert lucene.VERSION >= '3.1'
-if lucene.VERSION < '3.2':
-    warnings.warn('Support for lucene 3.1 will be removed in the next release.', DeprecationWarning)
+assert lucene.VERSION >= '3.2'
+if lucene.VERSION < '3.3':
+    warnings.warn('Support for lucene 3.2 will be removed in the next release.', DeprecationWarning)

File lupyne/engine/indexers.py

 import itertools, operator
 import contextlib
 import abc, collections
-import warnings
 import lucene
 from .queries import Query, Collector, TermsFilter, SortField, Highlighter, FastVectorHighlighter, SpellChecker, SpellParser
 from .documents import Field, Document, Hits
     def segments(self):
         "segment filenames with document counts"
         return dict((lucene.SegmentReader.cast_(reader).segmentName, reader.numDocs()) for reader in self.sequentialSubReaders)
-    def copy(self, dest, query=None, exclude=None, optimize=False, merge=0):
+    def copy(self, dest, query=None, exclude=None, merge=0):
         """Copy the index to the destination directory.
         Optimized to use hard links if the destination is a file system path.
         
         :param query: optional lucene Query to select documents
         :param exclude: optional lucene Query to exclude documents
         :param merge: optionally merge into maximum number of segments
-        :param optimize: .. deprecated:: 1.2 use **merge** param instead
         """
         copy(self.indexCommit, dest)
         with contextlib.closing(IndexWriter(dest)) as writer:
                 writer.delete(exclude)
             writer.commit()
             writer.expungeDeletes()
-            if optimize:
-                warnings.warn("Use merge=int instead of optimize parameter.", DeprecationWarning)
-                merge = int(optimize)
             if merge:
                 writer.optimize(merge)
             return len(writer)
     def refresh(self, **caches):
         "Store refreshed searcher with :meth:`IndexSearcher.reopen` caches."
         self.indexSearcher = self.indexSearcher.reopen(**caches)
-    def commit(self, expunge=False, optimize=False, merge=False, **caches):
+    def commit(self, merge=False, **caches):
         """Commit writes and :meth:`refresh` searcher.
         
         :param merge: merge segments with deletes, or optionally specify maximum number of segments
-        :param expunge,optimize: .. deprecated:: 1.2 use **merge** param instead
         """
         IndexWriter.commit(self)
-        if expunge:
-            warnings.warn("Use merge=True instead of expunge parameter.", DeprecationWarning)
-            self.expungeDeletes()
-            IndexWriter.commit(self)
-        if optimize:
-            warnings.warn("Use merge=int instead of optimize parameter.", DeprecationWarning)
-            merge = int(optimize)
         if merge:
             if isinstance(merge, bool):
                 self.expungeDeletes()

File lupyne/engine/spatial/__init__.py

 """
 
 import itertools
-import warnings
 import lucene
 from .globalmaptiles import GlobalMercator
 from ..queries import Query
             else:
                 slices.append((tile, tile + shift))
         return Query.any(*itertools.starmap(self.range, slices))
-    def filter(self, lng, lat, distance, lngfield, latfield, limit=Tiler.base):
-        """Return lucene LatLongDistanceFilter based on :meth:`within` query.
-        
-        .. deprecated:: 1.2 spatial contrib module deprecated as of lucene 3.6
-        """
-        filter = self.within(lng, lat, distance, limit).filter()
-        return DistanceFilter(filter, lng, lat, distance, lngfield, latfield)
 
 class PolygonField(PointField):
     """PointField which implicitly supports polygons (technically linear rings of points).
     def __getitem__(self, id):
         x, y = self.project(self.lats[id], self.lngs[id])
         return ((x - self.x)**2 + (y - self.y)**2) ** 0.5
-
-class DistanceFilter(getattr(lucene, 'LatLongDistanceFilter', object)):
-    "Inherited lucene LatLongDistanceFilter which supports the comparator interface."
-    meters = 1609.344
-    def __init__(self, filter, lng, lat, distance, lngfield, latfield):
-        warnings.warn('Spatial contrib module deprecated as of lucene 3.6.', DeprecationWarning)
-        lucene.LatLongDistanceFilter.__init__(self, filter, lat, lng, distance / self.meters, latfield, lngfield)
-    def __getitem__(self, id):
-        distance = self.getDistance(id)
-        if distance is None:
-            raise KeyError(id)
-        return distance.doubleValue() * self.meters
-    def sorter(self, reverse=False):
-        "Return lucene SortField based on the filter's cached distances."
-        return lucene.SortField('distance', lucene.DistanceFieldComparatorSource(self), reverse)

File lupyne/server.py

 def multi(value):
     return value and value.split(',')
 
-def mapping(value):
-    if isinstance(value, dict):
-        return value
-    cherrypy.response.headers['warning'] = '199 lupyne "use an object instead of an array"'
-    return dict.fromkeys(value, True)
-
 class params:
     "Parameter parsing."
     @staticmethod
         readers = reader.sequentialSubReaders if lucene.MultiReader.instance_(reader) else [reader]
         return dict((unicode(reader.directory()), reader.numDocs()) for reader in readers)
     @cherrypy.expose
-    @cherrypy.tools.json_in(process_body=mapping)
+    @cherrypy.tools.json_in(process_body=dict)
     @cherrypy.tools.allow(methods=['POST'])
     def update(self, **caches):
         """Refresh index version.
             self.refresh()
         return {unicode(self.indexer.directory): len(self.indexer)}
     @cherrypy.expose
-    @cherrypy.tools.json_in(process_body=mapping)
+    @cherrypy.tools.json_in(process_body=dict)
     @cherrypy.tools.allow(paths=[('POST',), ('GET', 'PUT', 'DELETE'), ('GET',)])
     def update(self, id='', name='', **options):
         """Commit index changes and refresh index version.

File test/local.py

         assert reader[0].dict() == {} and reader.count('text', '?') == 1
         assert len(reader.comparator('text')) == 4
         indexer.delete('text', '?')
-        with assertWarns(DeprecationWarning):
-            indexer.commit(expunge=True)
         indexer.commit(merge=True)
         assert not indexer.hasDeletions()
-        indexer.commit(merge=2)
-        with assertWarns(DeprecationWarning):
-            indexer.commit(optimize=True)
+        indexer.commit(merge=1)
         assert indexer.optimized
         del reader.indexReader
         self.assertRaises(AttributeError, getattr, reader, 'maxDoc')
         searcher = engine.IndexSearcher(directory)
         assert len(searcher) == size and list(searcher.terms('state')) == ['CA']
         path = os.path.join(self.tempdir, 'temp')
-        with assertWarns(DeprecationWarning):
-            size = indexer.copy(path, exclude=query, optimize=True)
+        size = indexer.copy(path, exclude=query, merge=1)
         assert len(searcher) + size == len(indexer)
         searcher = engine.IndexSearcher(path)
         assert searcher.optimized and 'CA' not in searcher.terms('state')
         assert 0 < len(hits) < sum(counts.values())
         hits = hits.sorted(distances.__getitem__, reverse=True)
         assert 0 == distances[hits.ids[-1]] < distances[hits.ids[0]] < 10**4
-        if hasattr(lucene, 'LatLongDistanceFilter'):
-            with assertWarns(DeprecationWarning):
-                f = field.filter(x, y, 10**4, 'longitude', 'latitude')
-            ids = indexer.search(query, sort=distances.__getitem__).ids
-            hits = indexer.search(count=10, filter=f, sort=f.sorter())
-            assert len(hits) < len(ids) and hits.ids == ids[:len(hits)]
-            assert all(f[id] <= distances[id] < 10**4 for id in hits.ids)
-            self.assertRaises(KeyError, f.__getitem__, -1)
     
     def testFields(self):
         "Custom fields."

File test/remote.py

             resource.post('/terms')
         with assertRaises(httplib.HTTPException, httplib.METHOD_NOT_ALLOWED):
             resource.get('/update')
-        with local.assertWarns(UserWarning):
-            resource.post('/update', [])
         with assertRaises(httplib.HTTPException, httplib.METHOD_NOT_ALLOWED):
             resource.post('/update/snapshot')
         with assertRaises(httplib.HTTPException, httplib.METHOD_NOT_ALLOWED):