Mercurial > p > roundup > code
annotate roundup/dist/command/build.py @ 5096:e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
Also adds new config.ini setting called indexer to select
indexer. See ``doc/upgrading.txt`` for details. Initial patch
done by David Wolever. Patch modified (see ticket or below for
changes), docs updated and committed.
I have an outstanding issue with test/test_indexer.py. I have to
comment out all imports and tests for indexers I don't have (i.e.
mysql, postgres) otherwise no tests run.
With that change made, dbm, sqlite (rdbms), xapian and whoosh indexes
are all passing the indexer tests.
Changes summary:
1) support native back ends dbm and rdbms. (original patch only fell
through to dbm)
2) Developed whoosh stopfilter to not index stopwords or words outside
the the maxlength and minlength limits defined in index_common.py.
Required to pass the extremewords test_indexer test. Also I
removed a call to .lower on the input text as the tokenizer I chose
automatically does the lowercase.
3) Added support for max/min length to find. This was needed to pass
extremewords test.
4) Added back a call to save_index in add_text. This allowed all but
two tests to pass.
5) Fixed a call to:
results = searcher.search(query.Term("identifier", identifier))
which had an extra parameter that is an error under current whoosh.
6) Set limit=None in search call for find() otherwise it only return
10 items. This allowed it to pass manyresults test
Also due to changes in the roundup code removed the call in
indexer_whoosh to
from roundup.anypy.sets_ import set
since we use the python builtin set.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 25 Jun 2016 20:10:03 -0400 |
| parents | 85dfe17c182e |
| children | 64b05e24dbd8 |
| rev | line source |
|---|---|
| 4068 | 1 # |
| 2 # Copyright (C) 2009 Stefan Seefeld | |
| 3 # All rights reserved. | |
| 4 # For license terms see the file COPYING.txt. | |
| 5 # | |
| 6 from roundup import msgfmt | |
| 7 from distutils.command.build import build as base | |
| 8 import os | |
| 9 from glob import glob | |
| 10 | |
| 11 def list_message_files(suffix=".po"): | |
| 12 """Return list of all found message files and their intallation paths""" | |
| 13 _files = glob("locale/*" + suffix) | |
| 14 _list = [] | |
| 15 for _file in _files: | |
| 16 # basename (without extension) is a locale name | |
| 17 _locale = os.path.splitext(os.path.basename(_file))[0] | |
| 18 _list.append((_file, os.path.join( | |
| 19 "share", "locale", _locale, "LC_MESSAGES", "roundup.mo"))) | |
| 20 return _list | |
| 21 | |
| 22 def check_manifest(): | |
| 23 """Check that the files listed in the MANIFEST are present when the | |
| 24 source is unpacked. | |
| 25 """ | |
| 26 try: | |
| 27 f = open('MANIFEST') | |
| 28 except: | |
| 29 print '\n*** SOURCE WARNING: The MANIFEST file is missing!' | |
| 30 return | |
| 31 try: | |
| 32 manifest = [l.strip() for l in f.readlines()] | |
| 33 finally: | |
| 34 f.close() | |
|
4394
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
35 err = set([line for line in manifest if not os.path.exists(line)]) |
| 4068 | 36 # ignore auto-generated files |
|
4394
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
37 err = err - set(['roundup-admin', 'roundup-demo', 'roundup-gettext', |
|
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
38 'roundup-mailgw', 'roundup-server', 'roundup-xmlrpc-server']) |
| 4068 | 39 if err: |
| 40 n = len(manifest) | |
| 41 print '\n*** SOURCE WARNING: There are files missing (%d/%d found)!'%( | |
| 42 n-len(err), n) | |
| 43 print 'Missing:', '\nMissing: '.join(err) | |
| 44 | |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
45 def build_message_files(command): |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
46 """For each locale/*.po, build .mo file in target locale directory""" |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
47 for (_src, _dst) in list_message_files(): |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
48 _build_dst = os.path.join("build", _dst) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
49 command.mkpath(os.path.dirname(_build_dst)) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
50 command.announce("Compiling %s -> %s" % (_src, _build_dst)) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
51 msgfmt.make(_src, _build_dst) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
52 |
| 4068 | 53 |
| 54 class build(base): | |
| 55 | |
| 56 def run(self): | |
| 57 check_manifest() | |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
58 build_message_files(self) |
| 4068 | 59 base.run(self) |
| 60 |
