Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
nexedi
converse.js
Commits
86f5a600
Commit
86f5a600
authored
Jul 31, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use FileStorage wrapper class
parent
d1712462
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
trans/search.py
trans/search.py
+13
-6
No files found.
trans/search.py
View file @
86f5a600
...
...
@@ -25,6 +25,7 @@ Whoosh based full text search.
import
whoosh
import
os
from
whoosh.fields
import
Schema
,
TEXT
,
ID
from
whoosh.filedb.filestore
import
FileStorage
from
django.db.models.signals
import
post_syncdb
from
weblate
import
appsettings
from
whoosh.index
import
create_in
,
open_dir
...
...
@@ -127,15 +128,21 @@ class Index(object):
_source
=
None
_target
=
{}
def
__init__
(
self
):
'''
Creates searcher object.
'''
self
.
storage
=
FileStorage
(
appsettings
.
WHOOSH_INDEX
)
def
source
(
self
):
'''
Returns source index.
'''
if
self
.
_source
is
None
:
try
:
self
.
_source
=
open_dir
(
appsettings
.
WHOOSH_INDEX
,
indexname
=
'source'
self
.
_source
=
self
.
storage
.
open_index
(
indexname
=
'source'
,
schema
=
SOURCE_SCHEMA
,
)
except
(
whoosh
.
index
.
EmptyIndexError
,
IOError
):
# eg. path or index does not exist
...
...
@@ -148,9 +155,9 @@ class Index(object):
'''
if
not
lang
in
self
.
_target
:
try
:
self
.
_target
[
lang
]
=
open_dir
(
appsettings
.
WHOOSH_INDEX
,
indexname
=
'target-%s'
%
lang
self
.
_target
[
lang
]
=
self
.
storage
.
open_index
(
indexname
=
'target-%s'
%
lang
,
schema
=
TARGET_SCHEMA
,
)
except
(
whoosh
.
index
.
EmptyIndexError
,
IOError
):
self
.
_target
[
lang
]
=
create_target_index
(
lang
)
...
...
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