MCPcopy Create free account
hub / github.com/C3ting/ARL / search

Method search

app/services/githubSearch.py:174–208  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

172 self.total_count = 0 # 保存搜索结果总数
173
174 def search(self):
175 try:
176 search_cnt = 0
177 total_search_cnt = len(self.built_in_rules)
178 for build_in in self.built_in_rules:
179 search_cnt += 1
180 build_in = build_in.strip()
181 if not build_in:
182 continue
183
184 curr_page = 1
185 query = "{} {}".format(self.query, build_in)
186 results, total_count = github_search_code(query=query, per_page=self.per_page, page=curr_page)
187 logger.info("[{}/{}] page:1 keyword:{} total:{}".format(search_cnt,
188 total_search_cnt, self.query, total_count))
189
190 self.total_count += total_count
191
192 # 对于根据文件来查的,应该只跑一页
193 if "filename:" not in build_in:
194 while (total_count / 100) > curr_page and curr_page < self.max_page:
195 curr_page += 1
196 next_results, total_count = github_search_code(query=query, per_page=self.per_page, page=curr_page)
197 logger.info("page:{} keyword:{} total:{}".format(curr_page, self.query, total_count))
198 results.extend(next_results)
199
200 for result in results:
201 if result not in self.results:
202 self.results.append(result)
203 except Exception as e:
204 logger.info("Error on {} {}".format(self.query, e))
205 logger.exception(e)
206
207 logger.info("{} search result {}".format(self.query, len(self.results)))
208 return self.results
209
210
211def github_search(keyword):

Callers 1

github_searchFunction · 0.95

Calls 1

github_search_codeFunction · 0.70

Tested by

no test coverage detected