1234567891011121314151617181920212223242526272829303132 |
- def iterate_repos_to_archive(self, repos: List[Repository.Repository], operation: str) -> List[Optional[str]]:
- """Iterate over each repository and start a thread if it can be archived.
- We ignore repos not in the include or in the exclude list if either are present.
- """
- logger = woodchips.get(LOGGER_NAME)
- pool = ThreadPoolExecutor(self.threads)
- thread_list = []
- for repo in repos:
- if (
- (not self.include and not self.exclude)
- or (self.include and repo.name in self.include)
- or (self.exclude and repo.name not in self.exclude)
- ):
- repo_owner_username = repo.owner.login.lower()
- repo_path = os.path.join(self.location, 'repos', repo_owner_username, repo.name)
- thread_list.append(
- pool.submit(
- self.archive_repo,
- repo=repo,
- repo_path=repo_path,
- operation=operation,
- )
- )
- else:
- logger.debug(f'{repo.name} skipped due to include/exclude filtering')
- wait(thread_list, return_when=ALL_COMPLETED)
- failed_repos = [repo.result() for repo in thread_list if repo.result()]
- return failed_repos
|