def gather_candidates(self, path: str = '' ) -> typing.List[typing.Dict[str, typing.Any]]: """ Returns file candidates """ if not path: path = self._cwd candidates = self._source.gather_candidates(self._context, Path(path)) if self._enabled_ignored_files: for glob in self._ignored_files: candidates = [ x for x in candidates if not x['action__path'].match(glob) ] return sort(self._sort_method, candidates)
def gather_candidates( self, path: str, base_level: int = 0) -> typing.List[Candidate]: """ Returns file candidates """ candidates = self._source.gather_candidates( self._context, Path(path)) if self._enabled_ignored_files: for glob in self._ignored_files: candidates = [x for x in candidates if not x['action__path'].match(glob)] for candidate in candidates: candidate['is_opened_tree'] = False candidate['is_root'] = False candidate['is_selected'] = False candidate['level'] = base_level return sort(self._sort_method, candidates)
def _gather_candidates(self, path: str, base_level: int = 0) -> typing.List[Candidate]: """ Returns file candidates """ if not self._source: return [] candidates = self._source.gather_candidates(self._context, Path(path)) if self._filtered_files != ['']: new_candidates = [] for candidate in candidates: matched = False for glob in self._filtered_files: if glob and candidate['action__path'].match(glob): matched = True break if matched or candidate['is_directory']: new_candidates.append(candidate) candidates = new_candidates if self._enabled_ignored_files: for glob in self._ignored_files: candidates = [ x for x in candidates if not glob or not x['action__path'].match(glob) ] for candidate in candidates: candidate['is_opened_tree'] = False candidate['is_root'] = False candidate['is_selected'] = False candidate['level'] = base_level return sort(self._sort_method, candidates)