コード例 #1
0
 def test_repo(self):
     repo = Repository('Jabref', 'jabref')
     repo.scrape()
     loader_repos = Loader('user')
     i = 0
     data_repos = loader_repos.load_data()
     for x in data_repos:
         i += 1
         if i == 1:
             self.assertEqual("1", x['total_pr'])
コード例 #2
0
 def test_repo(self):
     repo = Repository('Jabref', 'jabref')
     repo.scrape()
     loader_repos = Loader('repo')
     i = 0
     data_repos = loader_repos.load_data()
     for x in data_repos:
         i += 1
         if i == 1:
             self.assertEqual("jabref", x['name'])
             self.assertEqual("Jabref", x['login'])
コード例 #3
0
ファイル: test_pr.py プロジェクト: LimingZheng-NAU/INF502
 def test_repo(self):
     repo = Repository('Jabref', 'jabref')
     repo.scrape()
     loader_repos = Loader('repo')
     i = 0
     data_repos = loader_repos.load_data()
     for repo in data_repos:
         loader_prs = Loader('pr')
         loader_prs.set_login(repo['login'])
         loader_prs.set_name(repo['name'])
         data_prs = loader_prs.load_data()
         for data_pr in data_prs:
             i += 1
             if i == 1:
                 self.assertEqual("24", data_pr['number'])
             if i == 2:
                 self.assertEqual("20", data_pr['number'])
             if i == 3:
                 self.assertEqual("16", data_pr['number'])
             if i == 4:
                 self.assertEqual("15", data_pr['number'])
コード例 #4
0
def execute():
    # request the system to collect data for a specific repository
    if options.collect:
        # scrape repository specified
        repo = Repository(options.collect[0], args[0])
        repo.scrape()

        # scrape pull requests for this repository, including users
        pr = PullRequest(options.collect[0], args[0])
        pr.scrape()
        return

    # list all repos collected
    loader_repos = Loader('repo')
    data_repos = loader_repos.load_data()
    if options.repos:
        for data_repo in data_repos:
            description = data_repo['login'] + '/' + data_repo['name'] + ': ' + data_repo['description'] + ' (' + \
                          data_repo['watchers'] + ' of stars)'
            print(description)

    # list all pull requests from a repo (or summary)
    if options.pullrequest or options.summary:
        # list all repos for choosing
        print("Repositories: ")
        for data_repo in data_repos:
            description = data_repo['login'] + '/' + data_repo['name']
            print(description)

        # choose and list pull requests
        login_chosen = input("\nUsername (login): ")
        name_chosen = input("Repository Name: ")
        loader_prs = Loader('pr')
        loader_prs.set_login(login_chosen)
        loader_prs.set_name(name_chosen)
        data_prs = loader_prs.load_data()

        # output the detail
        if options.pullrequest:
            for data_pr in data_prs:
                description = 'title: ' + data_pr['title'] + ', number: ' + data_pr['number'] + ', state: ' + data_pr['state'] + ', by user: '******'user'] + ', commits: ' + data_pr['commits']
                print(description)

        # output summary
        if options.summary:
            pr_open = 0
            pr_closed = 0
            pr_users = []
            smallest_number = 999999
            oldest_date = ''
            for data_pr in data_prs:
                if data_pr['state'] == 'open':
                    pr_open += 1
                if data_pr['state'] == 'closed':
                    pr_closed += 1
                pr_users.append(data_pr['user'])
                if int(data_pr['number']) < smallest_number:
                    smallest_number = int(data_pr['number'])
                    oldest_date = data_pr['created_at']
            pr_users = len(set(pr_users))
            print("\nRepository Summary:\n")
            print("number of pull requests in 'open' state:", pr_open)
            print("number of pull requests in 'closed' state:", pr_closed)
            print("number of users:", pr_users)
            print("date of the oldest pull request:", oldest_date)
            # twitter data is located in user class

    # create graphics given a repo, or create graphics considering all pull requests from all repos
    if options.graph or options.allpr:
        graph = Graph()
        if options.graph:
            graph.set_repo(options.graph[0], args[0])
        graph.display()

    # calculate the correlation between the data collected for a user
    if options.usercorrelation:
        loader_repos = Loader('user')
        data_users = loader_repos.load_data()
        for user in data_users:
            co = np.corrcoef([int(user['followers']), int(user['following']), int(user['commit_last_year'])])
            print("Correlation: ", co)

    # calculate the correlation between all the numeric data in the pull requests for a repo
    if options.inprcorrelation:
        loader_repos = Loader('repo')
        data_repos = loader_repos.load_data()
        for repo in data_repos:
            loader_prs = Loader('pr')
            loader_prs.set_login(repo['login'])
            loader_prs.set_name(repo['name'])
            data_prs = loader_prs.load_data()
            for data_pr in data_prs:
                co = np.corrcoef([int(data_pr['number']), int(data_pr['commits']), int(data_pr['additions']), int(data_pr['deletions']), int(data_pr['changed_files'])])
                print("Correlation: ", co)