Show More
@@ -25,7 +25,7 b' Original author and date, and relevant c' | |||||
25 | :license: GPLv3, see LICENSE.md for more details. |
|
25 | :license: GPLv3, see LICENSE.md for more details. | |
26 | """ |
|
26 | """ | |
27 |
|
27 | |||
28 | from kallithea.lib.utils2 import __get_lem |
|
28 | from kallithea.lib.utils2 import __get_lem, __get_index_filenames | |
29 |
|
29 | |||
30 |
|
30 | |||
31 | # language map is also used by whoosh indexer, which for those specified |
|
31 | # language map is also used by whoosh indexer, which for those specified | |
@@ -38,7 +38,7 b' LANGUAGES_EXTENSIONS_MAP = __get_lem()' | |||||
38 | INDEX_EXTENSIONS = LANGUAGES_EXTENSIONS_MAP.keys() |
|
38 | INDEX_EXTENSIONS = LANGUAGES_EXTENSIONS_MAP.keys() | |
39 |
|
39 | |||
40 | # Filenames we want to index content of using whoosh |
|
40 | # Filenames we want to index content of using whoosh | |
41 | INDEX_FILENAMES = [] |
|
41 | INDEX_FILENAMES = __get_index_filenames() | |
42 |
|
42 | |||
43 | # list of readme files to search in file tree and display in summary |
|
43 | # list of readme files to search in file tree and display in summary | |
44 | # attached weights defines the search order lower is first |
|
44 | # attached weights defines the search order lower is first |
@@ -78,6 +78,25 b' def __get_lem():' | |||||
78 | return dict(d) |
|
78 | return dict(d) | |
79 |
|
79 | |||
80 |
|
80 | |||
|
81 | def __get_index_filenames(): | |||
|
82 | """ | |||
|
83 | Get list of known indexable filenames from pygment lexer internals | |||
|
84 | """ | |||
|
85 | from pygments import lexers | |||
|
86 | from itertools import ifilter | |||
|
87 | ||||
|
88 | filenames = [] | |||
|
89 | ||||
|
90 | def likely_filename(s): | |||
|
91 | return s.find('*') == -1 and s.find('[') == -1 | |||
|
92 | ||||
|
93 | for lx, t in sorted(lexers.LEXERS.items()): | |||
|
94 | for f in ifilter(likely_filename, t[-2]): | |||
|
95 | filenames.append(f) | |||
|
96 | ||||
|
97 | return filenames | |||
|
98 | ||||
|
99 | ||||
81 | def str2bool(_str): |
|
100 | def str2bool(_str): | |
82 | """ |
|
101 | """ | |
83 | returs True/False value from given string, it tries to translate the |
|
102 | returs True/False value from given string, it tries to translate the |
General Comments 0
You need to be logged in to leave comments.
Login now