annotate MoinMoin/script/index/build.py @ 946:72aeb2ba133d

support complete rebuild of the index
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Fri, 14 Jul 2006 15:12:34 +0200
parents 45e286183872
children 41f6f7708466
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
788
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - build xapian search engine's index
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 You must run this script as owner of the wiki files, usually this is the
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 web server user.
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8 @copyright: 2006 by MoinMoin:ThomasWaldmann
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 """
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11
809
8dbfb6826497 MoinMoin.script._util -> MoinMoin.script
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 789
diff changeset
12 from MoinMoin.script import MoinScript
788
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 class IndexScript(MoinScript):
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 """ Xapian general index script class """
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 def __init__(self, argv, def_values):
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 MoinScript.__init__(self, argv, def_values)
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 self.parser.add_option(
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 "--files", metavar="FILES", dest="file_list",
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 help="filename of file list, e.g. files.lst (one file per line)"
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 )
789
a1359eaee20e xapian search: some fixes, move mimetype stuff to wikiutil, add opendocument mimetypes, add opendocument filter modules
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 788
diff changeset
23 self.parser.add_option(
a1359eaee20e xapian search: some fixes, move mimetype stuff to wikiutil, add opendocument mimetypes, add opendocument filter modules
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 788
diff changeset
24 "--mode", metavar="MODE", dest="mode",
946
72aeb2ba133d support complete rebuild of the index
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 921
diff changeset
25 help="either add (unconditionally add to index), update (update an existing index) or rebuild (remove and add)"
789
a1359eaee20e xapian search: some fixes, move mimetype stuff to wikiutil, add opendocument mimetypes, add opendocument filter modules
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 788
diff changeset
26 )
788
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 def mainloop(self):
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 self.init_request()
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 # Do we have additional files to index?
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 if self.options.file_list:
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 self.files = file(self.options.file_list)
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 else:
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 self.files = None
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 self.command()
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 class PluginScript(IndexScript):
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 """ Xapian index build script class """
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 def command(self):
921
45e286183872 abstraction work on search engine index & cleanups
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 810
diff changeset
41 from MoinMoin.search.Xapian import Index
789
a1359eaee20e xapian search: some fixes, move mimetype stuff to wikiutil, add opendocument mimetypes, add opendocument filter modules
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 788
diff changeset
42 Index(self.request).indexPages(self.files, self.options.mode)
788
4840926790f5 indexed search: added Xapian support (needs more work), removed Lupy support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43