Skip to content

Commit

Permalink
change to inline function
Browse files Browse the repository at this point in the history
  • Loading branch information
edulauer committed Feb 19, 2024
1 parent 9829b9f commit ca55749
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/searchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def exec_search(self,
is_exact_search: bool,
ignore_signature_match: bool,
force_rematch: bool,
reference_date: datetime,
department: str):
department: str,
reference_date: datetime):
search_results = self._search_all_terms(
self._cast_term_list(term_list),
dou_sections,
Expand Down Expand Up @@ -160,7 +160,9 @@ def _search_all_terms(self,
results = [r for r in results
if self._really_matched(search_term,
r.get('abstract'))]
self._department_matched(results, department)
if department:
results = [r for r in results
if department in r.get('hierarchyList')]

self._render_section_descriptions(results)

Expand Down Expand Up @@ -244,16 +246,6 @@ def _is_signature(self, search_term: str, abstract: str) -> bool:
# ' JOSÉ `ANTONIO DE OLIVEIRA` MATOS'
norm_abstract_without_start_name.startswith(norm_term))
)

def _department_matched(self, results: list, department: str) -> list:
"""Verifica se o termo encontrado pela API realmente é igual ao
órgão de busca. Esta função é útil para filtrar resultados
retornardos pela API, mas que são específicas do órgão.
"""

for result in results[:]:
if not department in result["hierarchyList"]:
results.remove(result)

def _get_prior_and_matched_name(self, raw_html: str) -> Tuple[str, str]:
groups = self.SPLIT_MATCH_RE.match(raw_html).groups()
Expand Down

0 comments on commit ca55749

Please sign in to comment.