changeset 4671:83451b52e947

add compatibility code for set to xapwrap.index (py 2.6 emits warnings if you use Sets module
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 28 Mar 2009 13:13:23 +0100
parents 14017d47a003
children 357ad7160d15
files MoinMoin/support/xapwrap/index.py
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/support/xapwrap/index.py	Tue Mar 24 22:13:23 2009 +0100
+++ b/MoinMoin/support/xapwrap/index.py	Sat Mar 28 13:13:23 2009 +0100
@@ -118,7 +118,12 @@
 future version will.
 
 """
-import cPickle, sets, glob, os
+try:
+    set
+except:
+    from sets import Set as set
+
+import cPickle, glob, os
 import xapian
 from document import makePairForWrite, StandardAnalyzer, Document, SortKey, Keyword
 from document import UNICODE_ENCODING, UNICODE_ERROR_POLICY
@@ -973,8 +978,8 @@
             raise InvalidArgumentError(
                 "document UIDs must be greater than one when using SmartIndex")
 
-        docSortKeys = sets.Set([sk.name for sk in doc.sortFields if sk.name is not None])
-        indexSortKeys = sets.Set(self.indexValueMap.keys())
+        docSortKeys = set([sk.name for sk in doc.sortFields if sk.name is not None])
+        indexSortKeys = set(self.indexValueMap.keys())
         if not docSortKeys.issubset(indexSortKeys):
             nextValueIndex = 1 + max(self.indexValueMap.itervalues())
             # we sort the sortKeys in order to improve the odds that two
@@ -992,9 +997,9 @@
                     nextValueIndex += 2
             self.saveState()
 
-        docKeywords = sets.Set([tf.name for tf in doc.textFields if tf.prefix] +
+        docKeywords = set([tf.name for tf in doc.textFields if tf.prefix] +
                                [kw.name for kw in doc.keywords])
-        indexKeyWords = sets.Set(self.prefixMap.keys())
+        indexKeyWords = set(self.prefixMap.keys())
         if not docKeywords.issubset(indexKeyWords):
             for k in docKeywords - indexKeyWords:
                 self.prefixMap[k] = k.upper()