[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex - GlobbingLexicon.py:1.12

Andreas Jung andreas@digicool.com
Thu, 28 Feb 2002 08:43:24 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex
In directory cvs.zope.org:/tmp/cvs-serv305/lib/python/Products/PluginIndexes/TextIndex

Modified Files:
	GlobbingLexicon.py 
Log Message:
      - Collector #250: applied several patches for TextIndex for better
        unicode support for the GlobbingLexicon


=== Zope/lib/python/Products/PluginIndexes/TextIndex/GlobbingLexicon.py 1.11 => 1.12 ===
 from Products.PluginIndexes.TextIndex.TextIndex import Op
 
+from types import UnicodeType 
 
 class GlobbingLexicon(Lexicon):
     """Lexicon which supports basic globbing function ('*' and '?').
@@ -250,10 +251,16 @@
         """
 
         # Remove characters that are meaningful in a regex
-        transTable = string.maketrans("", "")
-        result = string.translate(pat, transTable,
-                                  r'()&|!@#$%^{}\<>.')
-        
+        if not isinstance(pat, UnicodeType):
+            transTable = string.maketrans("", "")
+            result = string.translate(pat, transTable,
+                                      r'()&|!@#$%^{}\<>.')
+        else:
+            transTable={}
+            for ch in r'()&|!@#$%^{}\<>.':
+                transTable[ord(ch)]=None
+            result=pat.translate(transTable)
+
         # First, deal with multi-character globbing
         result = result.replace( '*', '.*')