Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
ca1d97b2
Commit
ca1d97b2
authored
Feb 28, 2002
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Collector #250: applied several patches for TextIndex for better
unicode support for the GlobbingLexicon
parent
f4a0d46e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
4 deletions
+67
-4
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/Products/PluginIndexes/TextIndex/GlobbingLexicon.py
...ython/Products/PluginIndexes/TextIndex/GlobbingLexicon.py
+11
-4
lib/python/Products/PluginIndexes/TextIndex/tests/testTextIndex.py
...n/Products/PluginIndexes/TextIndex/tests/testTextIndex.py
+53
-0
No files found.
doc/CHANGES.txt
View file @
ca1d97b2
...
...
@@ -35,6 +35,9 @@ Zope Changes
to display unicode strings in the vocabulary properly (now using
UTF-8 encoding for display purposes)
- Collector #250: applied several patches for TextIndex for better
unicode support for the GlobbingLexicon
Zope 2.5.1 beta 1
...
...
lib/python/Products/PluginIndexes/TextIndex/GlobbingLexicon.py
View file @
ca1d97b2
...
...
@@ -26,6 +26,7 @@ from randid import randid
from
Products.PluginIndexes.TextIndex.TextIndex
import
Or
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 @@ class GlobbingLexicon(Lexicon):
"""
# 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
(
'*'
,
'.*'
)
...
...
lib/python/Products/PluginIndexes/TextIndex/tests/testTextIndex.py
View file @
ca1d97b2
...
...
@@ -221,6 +221,59 @@ class Tests(unittest.TestCase):
""" Check complex query 1 """
self
.
globTest
({
'text'
:
'((?ount* or get) and not wait) '
'"been *ert*"'
},
[
0
,
1
,
5
,
6
])
# same tests, unicode strings
def
checkStarQueryUnicode
(
self
):
"Check a star query (unicode)"
self
.
globTest
({
'text'
:
u'm*n'
},
[
0
,
2
])
def
checkAndQueryUnicode
(
self
):
"Check an AND query (unicode)"
self
.
globTest
({
'text'
:
u'time and country'
},
[
0
,])
def
checkOrQueryUnicode
(
self
):
"Check an OR query (unicode)"
self
.
globTest
({
'text'
:
u'time or country'
},
[
0
,
1
,
6
])
def
checkDefOrQueryUnicode
(
self
):
"Check a default OR query (unicode)"
self
.
globTest
({
'text'
:
u'time country'
},
[
0
,
1
,
6
])
def
checkNearQueryUnicode
(
self
):
"""Check a NEAR query.. (NOTE:ACTUALLY AN 'AND' TEST!!) (unicode)"""
# NEAR never worked, so Zopes post-2.3.1b3 define near to mean AND
self
.
globTest
({
'text'
:
u'time ... country'
},
[
0
,])
def
checkQuotesQueryUnicode
(
self
):
"""Check a quoted query (unicode)"""
ai
=
self
.
globTest
({
'text'
:
u'"This is the time"'
},
[
0
,])
r
=
list
(
ai
({
'text'
:
'"now is the time"'
})[
0
].
keys
())
assert
r
==
[],
r
def
checkAndNotQueryUnicode
(
self
):
"Check an ANDNOT query (unicode)"
self
.
globTest
({
'text'
:
u'time and not country'
},
[
6
,])
def
checkParenMatchingQueryUnicode
(
self
):
"Check a query with parens (unicode)"
ai
=
self
.
globTest
({
'text'
:
u'(time and country) men'
},
[
0
,])
r
=
list
(
ai
({
'text'
:
u'(time and not country) or men'
})[
0
].
keys
())
assert
r
==
[
0
,
6
],
r
def
checkTextIndexOperatorQueryUnicode
(
self
):
"Check a query with 'operator' in the request (unicode)"
self
.
globTest
({
'text'
:
{
u'query'
:
u'time men'
,
'operator'
:
'and'
}},
[
0
,])
def
checkNonExistentWordUnicode
(
self
):
""" Check for nonexistent word (unicode)"""
self
.
globTest
({
'text'
:
u'zop'
},
[])
def
checkComplexQuery1Unicode
(
self
):
""" Check complex query 1 (unicode)"""
self
.
globTest
({
'text'
:
u'((?ount* or get) and not wait) '
'"been *ert*"'
},
[
0
,
1
,
5
,
6
])
def
test_suite
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment