Exemplo n.º 1
0
    def test_user(self):

        u = github.user()
        u1 = github.user()

        self.assertTrue(u)
        # make sure hash works
        self.assertTrue(u is u1)
Exemplo n.º 2
0
    def draw(self):
    
        # get current buffer!
        b = utils.get_buffer(self.buffer_name)

        # set to markdown syntax for now
        vim.command("set filetype=markdown")

        # append title
        b.append("## %s" % self.repo)
        b.append("")
        
        for i in self.issues:
            issue_string = "%s. \"%s\" " % (i[0], i[1])

            if len(i[5]) > 0:
                 issue_string += "#%s " % ",".join(i[5])
            
            if not (i[2] == github.user()["login"]):
                issue_string += "@%s " % i[2]
            if not (i[3] == "open"):
                issue_string += i[3]
            
            # add labels if they exist
            b.append(issue_string)

        # delete first line
        vim.command("1delete _")
Exemplo n.º 3
0
async def test_follow_user(exec):
    user = gh.user('octocat')

    if live:
        assert await exec(user.follow())
        assert await exec(user.unfollow())
        assert not await exec(user.following())
Exemplo n.º 4
0
    def __init__(self, number, repo_uri):

        self.login = github.user().get("login")
        self.editable_comments = {}
        self.comments = OrderedDict()
        self.user_comments = [] # list of ids that will get updated each time
        self.repo_uri = repo_uri
        self.number = number
        self._get_comments()
Exemplo n.º 5
0
    def test_time_from_string(self):

        to = github.time(github.user().get("updated_at"))
Exemplo n.º 6
0
def load_data(organisation_name, update=False):
    data = {}
    path = '%s/%s.json' % (config.STORE, organisation_name)
    if os.path.exists(path) and not update:
        with open(path, 'rb') as f:
            data = json.loads(f.read())
    else:
        organisation = github.organisation(organisation_name)
        projects = [
            repository['name'] for repository in
            github.organisation_repositories(organisation_name)
        ]
        pull_request_map = {}
        pull_request_comments_map = {}
        pull_requests = []
        pull_request_comments = []
        projects_with_pulls = []
        user_data = {}
        project_data = {}

        for project in projects:
            pulls, comments = github.pull_requests_with_comments(
                organisation_name, project, state='closed')
            print '[load_data] %s: got %d pull requests with %d comments' % (
                project, len(pulls), len(comments))
            open_pulls, open_comments = github.pull_requests_with_comments(
                organisation_name, project, state='open')
            print '[load_data] %s: got %d open pull requests with %d comments' % (
                project, len(open_pulls), len(open_comments))

            for user in [
                    x['user']['login'] for x in pulls + open_pulls if x['user']
            ]:
                if user not in user_data:
                    print '[load_data] %s: caching user %s' % (project, user)
                    user_data[user] = github.user(user)

            if project not in project_data and (pulls + open_pulls):
                print '[load_data] caching project %s data' % project
                project_data[project] = (pulls
                                         or open_pulls)[0]['base']['repo']

            pulls += open_pulls
            comments += open_comments

            pull_request_map[project] = pulls
            pull_request_comments_map[project] = comments

            pull_requests += pulls
            pull_request_comments += comments

            if pulls:
                projects_with_pulls.append(project)

        data = {
            'pull_requests': pull_requests,
            'pull_requests_per_project': pull_request_map,
            'pull_request_comments': pull_request_comments,
            'pull_request_comments_per_project': pull_request_comments_map,
            'projects': projects,
            'projects_with_pulls': projects_with_pulls,
            'organisation': organisation,
            'user_data': user_data,
            'project_data': project_data,
        }
        with PersistentDict(path, 'c', format='json') as d:
            d.update(data)

    return data
Exemplo n.º 7
0
def load_data(organisation_name, update=False):
    data = {}
    path = '%s/%s.json' % (config.STORE, organisation_name)
    if os.path.exists(path) and not update:
        with open(path, 'rb') as f:
            data = json.loads(f.read())
    else:
        organisation = github.organisation(organisation_name)
        projects = [repository['name'] for repository in github.organisation_repositories(organisation_name)]
        pull_request_map = {}
        pull_request_comments_map = {}
        pull_requests = []
        pull_request_comments = []
        projects_with_pulls = []
        user_data = {}
        project_data = {}

        for project in projects:
            pulls, comments = github.pull_requests_with_comments(organisation_name, project, state='closed')
            print '[load_data] %s: got %d pull requests with %d comments' % (project, len(pulls), len(comments))
            open_pulls, open_comments = github.pull_requests_with_comments(organisation_name, project, state='open')
            print '[load_data] %s: got %d open pull requests with %d comments' % (project, len(open_pulls), len(open_comments))

            for user in [x['user']['login'] for x in pulls+open_pulls if x['user']]:
                if user not in user_data:
                    print '[load_data] %s: caching user %s' % (project, user)
                    user_data[user] = github.user(user)

            if project not in project_data and (pulls+open_pulls):
                print '[load_data] caching project %s data' % project
                project_data[project] = (pulls or open_pulls)[0]['base']['repo'] 

            pulls += open_pulls
            comments += open_comments

            pull_request_map[project] = pulls
            pull_request_comments_map[project] = comments

            pull_requests += pulls
            pull_request_comments += comments

            if pulls:
                projects_with_pulls.append(project)

        data = {
            'pull_requests'                    : pull_requests,
            'pull_requests_per_project'        : pull_request_map,

            'pull_request_comments'            : pull_request_comments,
            'pull_request_comments_per_project': pull_request_comments_map,

            'projects'                         : projects,
            'projects_with_pulls'              : projects_with_pulls,
            'organisation'                     : organisation,

            'user_data'                        : user_data,
            'project_data'                     : project_data,
        }
        with PersistentDict(path, 'c', format='json') as d:
            d.update(data)

    return data