Package xappy :: Module _checkxapian
[frames] | no frames]

Source Code for Module xappy._checkxapian

 1  # Copyright (C) 2008 Lemur Consulting Ltd 
 2  # 
 3  # This program is free software; you can redistribute it and/or modify 
 4  # it under the terms of the GNU General Public License as published by 
 5  # the Free Software Foundation; either version 2 of the License, or 
 6  # (at your option) any later version. 
 7  # 
 8  # This program is distributed in the hope that it will be useful, 
 9  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
10  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
11  # GNU General Public License for more details. 
12  #  
13  # You should have received a copy of the GNU General Public License along 
14  # with this program; if not, write to the Free Software Foundation, Inc., 
15  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
16  r"""_checkxapian.py: Check the version of xapian used. 
17   
18  Raises an ImportError on import if the version used is too old to be used at 
19  all. 
20   
21  """ 
22  __docformat__ = "restructuredtext en" 
23   
24  # The minimum version of xapian required to work at all. 
25  min_xapian_version = (1, 0, 6) 
26   
27  # Dictionary of features we can't support do to them being missing from the 
28  # available version of xapian. 
29  missing_features = {} 
30   
31  import xapian 
32   
33  versions = xapian.major_version(), xapian.minor_version(), xapian.revision() 
34   
35   
36  if versions < min_xapian_version: 
37      raise ImportError(""" 
38          Xapian Python bindings installed, but need at least version %d.%d.%d - got %s 
39          """.strip() % tuple(list(min_xapian_version) + [xapian.version_string()])) 
40   
41  if not hasattr(xapian, 'TermCountMatchSpy'): 
42      missing_features['tags'] = 1 
43  if not hasattr(xapian, 'CategorySelectMatchSpy'): 
44      missing_features['facets'] = 1 
45