# HG changeset patch # User Takumi IINO # Date 1445603816 -3600 # Node ID 130f8e170d3caf452383d87ede5572d1a770881e # Parent 2b7a0e28c4dc5e558c4912003f9bdee9ff2f1060 indexers: get default filenames for indexing from lexer definitions diff -r 2b7a0e28c4dc -r 130f8e170d3c kallithea/config/conf.py --- 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 diff -r 2b7a0e28c4dc -r 130f8e170d3c kallithea/lib/utils2.py --- 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