Changeset - 130f8e170d3c
[Not reviewed]
default
0 2 0
Takumi IINO - 10 years ago 2015-10-23 14:36:56
trot.thunder@gmail.com
indexers: get default filenames for indexing from lexer definitions
2 files changed with 21 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/config/conf.py
Show inline comments
 
@@ -22,26 +22,26 @@ Original author and date, and relevant c
 
:created_on: Mar 7, 2012
 
:author: marcink
 
:copyright: (c) 2013 RhodeCode GmbH, and others.
 
:license: GPLv3, see LICENSE.md for more details.
 
"""
 

	
 
from kallithea.lib.utils2 import __get_lem
 
from kallithea.lib.utils2 import __get_lem, __get_index_filenames
 

	
 

	
 
# language map is also used by whoosh indexer, which for those specified
 
# extensions will index it's content
 
LANGUAGES_EXTENSIONS_MAP = __get_lem()
 

	
 
# Whoosh index targets
 

	
 
# Extensions we want to index content of using whoosh
 
INDEX_EXTENSIONS = LANGUAGES_EXTENSIONS_MAP.keys()
 

	
 
# Filenames we want to index content of using whoosh
 
INDEX_FILENAMES = []
 
INDEX_FILENAMES = __get_index_filenames()
 

	
 
# list of readme files to search in file tree and display in summary
 
# attached weights defines the search  order lower is first
 
ALL_READMES = [
 
    ('readme', 0), ('README', 0), ('Readme', 0),
 
    ('doc/readme', 1), ('doc/README', 1), ('doc/Readme', 1),
kallithea/lib/utils2.py
Show inline comments
 
@@ -75,12 +75,31 @@ def __get_lem():
 
                desc = lx.replace('Lexer', '')
 
                d[ext].append(desc)
 

	
 
    return dict(d)
 

	
 

	
 
def __get_index_filenames():
 
    """
 
    Get list of known indexable filenames from pygment lexer internals
 
    """
 
    from pygments import lexers
 
    from itertools import ifilter
 

	
 
    filenames = []
 

	
 
    def likely_filename(s):
 
        return s.find('*') == -1 and s.find('[') == -1
 

	
 
    for lx, t in sorted(lexers.LEXERS.items()):
 
        for f in ifilter(likely_filename, t[-2]):
 
            filenames.append(f)
 

	
 
    return filenames
 

	
 

	
 
def str2bool(_str):
 
    """
 
    returs True/False value from given string, it tries to translate the
 
    string into boolean
 

	
 
    :param _str: string value to translate into boolean
0 comments (0 inline, 0 general)