def get_issues_for_projects(projects, show_progress): if show_progress: progress_bar = ProgressBar(maxval=len(projects), widgets=[ 'Progress: ', Percentage(), ' ', Bar(marker=RotatingMarker()), ' ', ETA(), ' Processing project ', Counter(), ' / ' + str(len(projects)) + '.' ]) progress_bar.start() # Create a new fetch index last_fetch_index = GitHubProject.select(fn.Max(GitHubProject.fetch_index)).scalar() or 0 fetch_index = last_fetch_index + 1 for project_index, project in enumerate(projects, start=1): # Create a new record for the project based on the JSON specification project = GitHubProject.create( fetch_index=fetch_index, name=project['name'], owner=project['owner'], repo=project['repo'], ) # Wrap a callback that will save issues associated to this project and fetch index. save_issues_callback = functools.partial( save_issues, project=project, fetch_index=fetch_index, ) # Fetch all issues for the project from GitHub github_get( start_url=GITHUB_API_URL + '/repos/' + project.owner + '/' + project.repo + '/issues', results_callback=save_issues_callback, params={ 'state': 'all', } ) if show_progress: progress_bar.update(project_index) if show_progress: progress_bar.finish()