comparison rhodecode/lib/indexers/__init__.py @ 1231:9f6560667743

fixes for stable
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 09 Apr 2011 17:13:15 +0200
parents 277427ac29a9
children bf263968da47
comparison
equal deleted inserted replaced
1228:73434499fa72 1231:9f6560667743
1 # -*- coding: utf-8 -*-
2 """
3 rhodecode.lib.indexers.__init__
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 Whoosh indexing module for RhodeCode
7
8 :created_on: Aug 17, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1 import os 25 import os
2 import sys 26 import sys
3 import traceback 27 import traceback
4 from os.path import dirname as dn, join as jn 28 from os.path import dirname as dn, join as jn
5 29
6 #to get the rhodecode import 30 #to get the rhodecode import
7 sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) 31 sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
32
33 from string import strip
8 34
9 from rhodecode.model import init_model 35 from rhodecode.model import init_model
10 from rhodecode.model.scm import ScmModel 36 from rhodecode.model.scm import ScmModel
11 from rhodecode.config.environment import load_environment 37 from rhodecode.config.environment import load_environment
12 from rhodecode.lib.utils import BasePasterCommand, Command, add_cache 38 from rhodecode.lib.utils import BasePasterCommand, Command, add_cache
133 *Requires* implementation of ``__getitem__`` method. 159 *Requires* implementation of ``__getitem__`` method.
134 """ 160 """
135 for docid in self.doc_ids: 161 for docid in self.doc_ids:
136 yield self.get_full_content(docid) 162 yield self.get_full_content(docid)
137 163
138 def __getslice__(self, i, j): 164 def __getitem__(self, key):
139 """ 165 """
140 Slicing of resultWrapper 166 Slicing of resultWrapper
141 """ 167 """
168 i, j = key.start, key.stop
169
142 slice = [] 170 slice = []
143 for docid in self.doc_ids[i:j]: 171 for docid in self.doc_ids[i:j]:
144 slice.append(self.get_full_content(docid)) 172 slice.append(self.get_full_content(docid))
145 return slice 173 return slice
146 174