def run(token):
    insights = []
    authorization = f'token {token}'
    headers = {'Accept': 'application/vnd.github.v3+json', 'Authorization': authorization}
    for repository in repositories:
        repo_url = f'https://api.github.com/repos/ZupIT/{repository}'
        print(f"🐙 Getting insights for ZupIT's [36m{repository}[0m repository.")
        traffic = requests.get(url=(repo_url + '/traffic/views'), headers=headers).json()
        clones = requests.get(url=(repo_url + '/traffic/clones'), headers=headers).json()
        contributors = requests.get(url=(repo_url + '/contributors'), headers=headers).json()
        repo_stats = requests.get(url=repo_url, headers=headers).json()
        try:
            clones = clones['count']
        except (IndexError, KeyError):
            clones = '-'
        try:
            forks = repo_stats['forks_count']
        except (IndexError, KeyError):
            forks = '-'
        try:
            stars = repo_stats['stargazers_count']
        except (IndexError, KeyError):
            stars = '-'
        try:
            watchers = repo_stats['subscribers_count']
        except (IndexError, KeyError):
            watchers = '-'
        try:
            views = traffic['count']
        except (IndexError, KeyError):
            views = '-'
        try:
            uniques = traffic['uniques']
        except (IndexError, KeyError):
            uniques = '-'
        insights.append({'repo': repository, 'views': views, 'uniques': uniques, 'clones': clones, 'contributors': len(contributors), 'contributors_list': contributors, 'forks': forks, 'stars': stars, 'watchers': watchers})
    create_csv_file(insights)
def run(token):
    insights = []
    authorization = f'token {token}'
    headers = {'Accept': 'application/vnd.github.v3+json', 'Authorization': authorization}
    for repository in repositories:
        repo_url = f'https://api.github.com/repos/ZupIT/{repository}'
        print(f"🐙 Getting insights for ZupIT's [36m{repository}[0m repository.")
        traffic = requests.get(url=(repo_url + '/traffic/views'), headers=headers).json()
        clones = requests.get(url=(repo_url + '/traffic/clones'), headers=headers).json()
        contributors = requests.get(url=(repo_url + '/contributors'), headers=headers).json()
        repo_stats = requests.get(url=repo_url, headers=headers).json()
        try:
            clones = clones['count']
        except (IndexError, KeyError):
            clones = '-'
        try:
            forks = repo_stats['forks_count']
        except (IndexError, KeyError):
            forks = '-'
        try:
            stars = repo_stats['stargazers_count']
        except (IndexError, KeyError):
            stars = '-'
        try:
            watchers = repo_stats['subscribers_count']
        except (IndexError, KeyError):
            watchers = '-'
        try:
            views = traffic['count']
        except (IndexError, KeyError):
            views = '-'
        try:
            uniques = traffic['uniques']
        except (IndexError, KeyError):
            uniques = '-'
        insights.append({'repo': repository, 'views': views, 'uniques': uniques, 'clones': clones, 'contributors': len(contributors), 'contributors_list': contributors, 'forks': forks, 'stars': stars, 'watchers': watchers})
    create_csv_file(insights)