Back to index

moin  1.9.0~rc2
_checkxapian.py
Go to the documentation of this file.
00001 # Copyright (C) 2008 Lemur Consulting Ltd
00002 #
00003 # This program is free software; you can redistribute it and/or modify
00004 # it under the terms of the GNU General Public License as published by
00005 # the Free Software Foundation; either version 2 of the License, or
00006 # (at your option) any later version.
00007 #
00008 # This program is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 # GNU General Public License for more details.
00012 # 
00013 # You should have received a copy of the GNU General Public License along
00014 # with this program; if not, write to the Free Software Foundation, Inc.,
00015 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 r"""_checkxapian.py: Check the version of xapian used.
00017 
00018 Raises an ImportError on import if the version used is too old to be used at
00019 all.
00020 
00021 """
00022 __docformat__ = "restructuredtext en"
00023 
00024 # The minimum version of xapian required to work at all.
00025 min_xapian_version = (1, 0, 6)
00026 
00027 # Dictionary of features we can't support do to them being missing from the
00028 # available version of xapian.
00029 missing_features = {}
00030 
00031 import xapian
00032 
00033 versions = xapian.major_version(), xapian.minor_version(), xapian.revision()
00034 
00035 
00036 if versions < min_xapian_version:
00037     raise ImportError("""
00038         Xapian Python bindings installed, but need at least version %d.%d.%d - got %s
00039         """.strip() % tuple(list(min_xapian_version) + [xapian.version_string()]))
00040 
00041 if not hasattr(xapian, 'TermCountMatchSpy'):
00042     missing_features['tags'] = 1
00043 if not hasattr(xapian, 'CategorySelectMatchSpy'):
00044     missing_features['facets'] = 1