Mercurial > kallithea
changeset 5559:130f8e170d3c
indexers: get default filenames for indexing from lexer definitions
author | Takumi IINO <trot.thunder@gmail.com> |
---|---|
date | Fri, 23 Oct 2015 13:36:56 +0100 |
parents | 2b7a0e28c4dc |
children | 6ed126ef71af |
files | kallithea/config/conf.py kallithea/lib/utils2.py |
diffstat | 2 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/config/conf.py Sat Oct 17 00:12:50 2015 +0900 +++ b/kallithea/config/conf.py Fri Oct 23 13:36:56 2015 +0100 @@ -25,7 +25,7 @@ :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 @@ -38,7 +38,7 @@ 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
--- a/kallithea/lib/utils2.py Sat Oct 17 00:12:50 2015 +0900 +++ b/kallithea/lib/utils2.py Fri Oct 23 13:36:56 2015 +0100 @@ -78,6 +78,25 @@ 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