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
d73fd4c3
Commit
d73fd4c3
authored
Feb 03, 2010
by
I want to see all private code of nexedi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Treat fullwidth space characters defined in Unicode as valid whitespace.
Patch by Manabu TERADA.
parent
db3e078e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
src/Products/ZCTextIndex/QueryParser.py
src/Products/ZCTextIndex/QueryParser.py
+12
-1
src/Products/ZCTextIndex/tests/testQueryParser.py
src/Products/ZCTextIndex/tests/testQueryParser.py
+12
-0
No files found.
src/Products/ZCTextIndex/QueryParser.py
View file @
d73fd4c3
...
...
@@ -94,6 +94,11 @@ _tokenizer_regex = re.compile(r"""
)
"""
,
re
.
VERBOSE
)
# Use unicode regex to treat fullwidth space characters defined in Unicode
# as valid whitespace.
_tokenizer_unicode_regex
=
re
.
compile
(
_tokenizer_regex
.
pattern
,
_tokenizer_regex
.
flags
|
re
.
UNICODE
)
class
QueryParser
:
implements
(
IQueryParser
)
...
...
@@ -109,6 +114,12 @@ class QueryParser:
def
parseQuery
(
self
,
query
):
# Lexical analysis.
try
:
# Try to use unicode and treat fullwidth whitespace as valid one.
if
not
isinstance
(
query
,
unicode
):
query
=
query
.
decode
(
'utf-8'
)
tokens
=
_tokenizer_unicode_regex
.
findall
(
query
)
except
UnicodeDecodeError
:
tokens
=
_tokenizer_regex
.
findall
(
query
)
self
.
_tokens
=
tokens
# classify tokens
...
...
src/Products/ZCTextIndex/tests/testQueryParser.py
View file @
d73fd4c3
...
...
@@ -210,6 +210,18 @@ class TestQueryParser(TestQueryParserBase):
self
.
expect
(
"foo* bar"
,
AndNode
([
GlobNode
(
"foo*"
),
AtomNode
(
"bar"
)]))
def
test024
(
self
):
# Split by UTF-8 fullwidth space
from
Products.ZCTextIndex.ParseTree
import
AndNode
from
Products.ZCTextIndex.ParseTree
import
AtomNode
self
.
expect
(
"foo
\
xe3
\
x80
\
x80
bar"
,
AndNode
([
AtomNode
(
"foo"
),
AtomNode
(
"bar"
)]))
def
test025
(
self
):
# Split by Unicode fullwidth space
from
Products.ZCTextIndex.ParseTree
import
AndNode
from
Products.ZCTextIndex.ParseTree
import
AtomNode
self
.
expect
(
u"foo
\
u3000
bar"
,
AndNode
([
AtomNode
(
u"foo"
),
AtomNode
(
u"bar"
)]))
def
test101
(
self
):
self
.
failure
(
""
)
...
...
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