예제 #1
0
파일: tasks.py 프로젝트: q210/rhodecode
 def aggregate(cs):
     for f in cs[2]:
         ext = lower(f.extension)
         if ext in LANGUAGES_EXTENSIONS_MAP.keys() and not f.is_binary:
             if ext in code_stats:
                 code_stats[ext] += 1
             else:
                 code_stats[ext] = 1
예제 #2
0
from whoosh.formats import Characters
from whoosh.highlight import highlight, SimpleFragmenter, HtmlFormatter

from webhelpers.html.builder import escape
from sqlalchemy import engine_from_config
from vcs.utils.lazy import LazyProperty

from rhodecode.model import init_model
from rhodecode.model.scm import ScmModel
from rhodecode.model.repo import RepoModel
from rhodecode.config.environment import load_environment
from rhodecode.lib import LANGUAGES_EXTENSIONS_MAP
from rhodecode.lib.utils import BasePasterCommand, Command, add_cache

#EXTENSIONS WE WANT TO INDEX CONTENT OFF
INDEX_EXTENSIONS = LANGUAGES_EXTENSIONS_MAP.keys()

#CUSTOM ANALYZER wordsplit + lowercase filter
ANALYZER = RegexTokenizer(expression=r"\w+") | LowercaseFilter()


#INDEX SCHEMA DEFINITION
SCHEMA = Schema(owner=TEXT(),
                repository=TEXT(stored=True),
                path=TEXT(stored=True),
                content=FieldType(format=Characters(ANALYZER),
                             scorable=True, stored=True),
                modtime=STORED(), extension=TEXT(stored=True))


IDX_NAME = 'HG_INDEX'