MCPcopy
hub / github.com/lektor/lektor / _process_search_results

Function _process_search_results

lektor/sourcesearch.py:70–104  ·  view source on GitHub ↗
(builder, cur, alt, lang, limit)

Source from the content-addressed store, hash-verified

68
69
70def _process_search_results(builder, cur, alt, lang, limit):
71 mapping = _mapping_from_cursor(cur)
72 rv = []
73
74 files_needed = set()
75
76 for path, infos in mapping.items():
77 info = _find_best_info(infos, alt, lang)
78 if info is None:
79 continue
80
81 for parent in _iter_parents(path):
82 if parent not in mapping:
83 files_needed.add(parent)
84
85 rv.append(info)
86 if len(rv) == limit:
87 break
88
89 if files_needed:
90 cur.execute(
91 """
92 select path, alt, lang, type, title
93 from source_info
94 where path in (%s)
95 """
96 % ", ".join(["?"] * len(files_needed)),
97 list(files_needed),
98 )
99 mapping.update(_mapping_from_cursor(cur))
100
101 for info in rv:
102 info["parents"] = _build_parent_path(info["path"], mapping, alt, lang)
103
104 return rv
105
106
107def find_files(builder, query, alt=PRIMARY_ALT, lang=None, limit=50, types=None):

Callers 1

find_filesFunction · 0.85

Calls 7

_mapping_from_cursorFunction · 0.85
_find_best_infoFunction · 0.85
_iter_parentsFunction · 0.85
_build_parent_pathFunction · 0.85
itemsMethod · 0.45
appendMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected