scripts/github_stats.py
def get_stats(self, username='', password='', organization='llnl',
        force=True, repo_type='public'):
        """
        Retrieves the statistics from the given organization with the given
        credentials. Will not retreive data if file exists and force hasn't been
        set to True. This is to save GH API requests.
        """
        date = str(datetime.date.today())
        file_path =  ('../github_stats_output/' + date[:4] + '/' + date[:7] + '/'
            + date + '.csv')
        if force or not os.path.isfile(file_path):
            my_github.login(username, password)
            calls_beginning = self.logged_in_gh.ratelimit_remaining + 1
            print 'Rate Limit: ' + str(calls_beginning)
            my_github.get_org(organization)
            count_members = my_github.get_mems_of_org()
            count_teams = my_github.get_teams_of_org()
            my_github.repos(repo_type=repo_type, organization=organization)
            #Write JSON
            my_github.write_org_json(dict_to_write=self.members_json,
                path_ending_type='members', is_list=True)
            my_github.write_org_json(dict_to_write=
                {'singleton': self.org_retrieved.to_json()},
                path_ending_type='organization')
            my_github.write_org_json(dict_to_write=self.teams_json,
                path_ending_type='teams', is_list=True)

            my_github.write_repo_json(dict_to_write=self.repos_json,
                path_ending_type='repo')
            my_github.write_repo_json(dict_to_write=self.contributors_json,
                path_ending_type='contributors', is_list=True)
            my_github.write_repo_json(dict_to_write=self.pull_requests_json,
                path_ending_type='pull-requests', is_list=True)
            my_github.write_repo_json(dict_to_write=self.issues_json,
                path_ending_type='issues', is_list=True)
            my_github.write_repo_json(dict_to_write=self.languages_json,
                path_ending_type='languages', is_dict=True)
            my_github.write_repo_json(dict_to_write=self.commits_json,
                path_ending_type='commits', is_list=True)
            #Write CSV
            my_github.write_to_file(file_path,
                                    date,
                                    organization,
                                    count_members,
                                    count_teams)
            calls_remaining = self.logged_in_gh.ratelimit_remaining
            calls_used = calls_beginning - calls_remaining
            print ('Rate Limit Remaining: ' + str(calls_remaining) + '\nUsed '
                + str(calls_used) + ' API calls.')
def get_stats(self, username='', password='', organization='llnl',
        force=True, repo_type='public'):
        """
        Retrieves the statistics from the given organization with the given
        credentials. Will not retreive data if file exists and force hasn't been
        set to True. This is to save GH API requests.
        """
        date = str(datetime.date.today())
        file_path =  ('../github_stats_output/' + date[:4] + '/' + date[:7] + '/'
            + date + '.csv')
        if force or not os.path.isfile(file_path):
            my_github.login(username, password)
            calls_beginning = self.logged_in_gh.ratelimit_remaining + 1
            print 'Rate Limit: ' + str(calls_beginning)
            my_github.get_org(organization)
            count_members = my_github.get_mems_of_org()
            count_teams = my_github.get_teams_of_org()
            my_github.repos(repo_type=repo_type, organization=organization)
            #Write JSON
            my_github.write_org_json(dict_to_write=self.members_json,
                path_ending_type='members', is_list=True)
            my_github.write_org_json(dict_to_write=
                {'singleton': self.org_retrieved.to_json()},
                path_ending_type='organization')
            my_github.write_org_json(dict_to_write=self.teams_json,
                path_ending_type='teams', is_list=True)

            my_github.write_repo_json(dict_to_write=self.repos_json,
                path_ending_type='repo')
            my_github.write_repo_json(dict_to_write=self.contributors_json,
                path_ending_type='contributors', is_list=True)
            my_github.write_repo_json(dict_to_write=self.pull_requests_json,
                path_ending_type='pull-requests', is_list=True)
            my_github.write_repo_json(dict_to_write=self.issues_json,
                path_ending_type='issues', is_list=True)
            my_github.write_repo_json(dict_to_write=self.languages_json,
                path_ending_type='languages', is_dict=True)
            my_github.write_repo_json(dict_to_write=self.commits_json,
                path_ending_type='commits', is_list=True)
            #Write CSV
            my_github.write_to_file(file_path,
                                    date,
                                    organization,
                                    count_members,
                                    count_teams)
            calls_remaining = self.logged_in_gh.ratelimit_remaining
            calls_used = calls_beginning - calls_remaining
            print ('Rate Limit Remaining: ' + str(calls_remaining) + '\nUsed '
                + str(calls_used) + ' API calls.')
Retrieves the statistics from the given organization with the given
        credentials. Will not retreive data if file exists and force hasn't been
        set to True. This is to save GH API requests.