Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def expand(
self, parents: List[SearchLevel], check: bool = True
) -> (bool, Union[SearchResult, List[Node]]):
result = parents[-1].result.value
# logger.debug(f"Expanding {parents}")
# Deduplication
if not self._config().cache.mark_ctext(result):
return False, []
if check and type(result) == self._final_type:
check_res = self._checker(result)
if check_res is not None:
return True, SearchResult(path=parents, check_res=check_res)
success, dec_res = self.handleDecodings(result)
if success:
return True, SearchResult(path=parents + [dec_res[0]], check_res=dec_res[1])
nodes: List[Node] = []
for decoding in dec_res:
# Don't check, as handleDecodings did that for us
success, eval_res = self.expand(parents + [decoding], check=False)
if success:
return True, eval_res
nodes.extend(eval_res)
crackers: List[Cracker] = registry[Cracker[type(result)]]
expected_time: float
) -> (bool, Union[SearchResult, List[Node]]):
result = parents[-1].result.value
# logger.debug(f"Expanding {parents}")
# Deduplication
if not self._config().cache.mark_ctext(result):
return False, []
if check and type(result) == self._final_type:
check_res = self._checker(result)
if check_res is not None:
return True, SearchResult(path=parents, check_res=check_res)
success, dec_res = self.handleDecodings(result)
if success:
return True, SearchResult(path=parents + [dec_res[0]], check_res=dec_res[1])
nodes: List[Node] = []
for decoding in dec_res:
# Don't check, as handleDecodings did that for us
success, eval_res = self.expand(parents + [decoding], check=False)
if success:
return True, eval_res
nodes.extend(eval_res)
crackers: List[Cracker] = registry[Cracker[type(result)]]
expected_time: float
# Worth doing this check twice to simplify code and allow a early return for decodings
if type(result) == self._final_type:
expected_time = self._checker.getExpectedRuntime(result)