Сводка самых популярных репозиториев

We use cookies. Read the Privacy and Cookie Policy

При построении визуализации этих данных на диаграмму необходимо нанести более одного репозитория. Напишем цикл для вывода информации о каждом репозитории, возвращаемом вызовом API, чтобы все эти репозитории можно было включить в визуализацию:

python_repos.py

...

# Анализ информации о репозиториях.

repo_dicts = response_dict['items']

print("Repositories returned:", len(repo_dicts))

(1) print(" Selected information about each repository:")

(2)for repo_dict in repo_dicts:

. .print(' Name:', repo_dict['name'])

. .print('Owner:', repo_dict['owner']['login'])

. .print('Stars:', repo_dict['stargazers_count'])

. .print('Repository:', repo_dict['html_url'])

. .print('Description:', repo_dict['description'])

В точке (1) выводится приветственное сообщение. В точке (2) перебираются все словари в repo_dicts. Внутри цикла выводится имя каждого проекта, его владелец, количество звезд, URL на GitHub и краткое описание проекта:

Status code: 200

Total repositories: 713067

Repositories returned: 30

Selected information about each repository:

Name: httpie

Owner: jkbrzt

Stars: 16101

Repository: https://github.com/jkbrzt/httpie

Description: CLI HTTP client; user-friendly cURL replacement featuring

intuitive UI, JSON support, syntax highlighting, wget-like downloads,

extensions, etc.

Name: django

Owner: django

Stars: 15028

Repository: https://github.com/django/django

Description: The Web framework for perfectionists with deadlines.

...

Name: powerline

Owner: powerline

Stars: 4315

Repository: https://github.com/powerline/powerline

Description: Powerline is a statusline plugin for vim, and provides

statuslines and prompts for several other applications, including zsh, bash,

tmux, IPython, Awesome and Qtile.

В этих результатах встречаются интересные проекты; возможно, вам стоит присмотреться к некоторым из них… Но не увлекайтесь, потому что мы собираемся создать визуализацию, которая существенно упростит чтение результатов.