Exemplo n.º 1
0
 def get_repos(self, type=GithubObject.NotSet):
     assert type is GithubObject.NotSet or isinstance(type, str), type
     url_parameters = dict()
     if type is not GithubObject.NotSet:
         url_parameters["type"] = type
     return PaginatedList.PaginatedList(repo.Repo, self._requester,
                                        self.url + "/repos", url_parameters)
Exemplo n.º 2
0
 def get_starred(self):
     return PaginatedList.PaginatedList(
         repo.Repo,
         self._requester,
         self.url + "/starred",
         None
     )
Exemplo n.º 3
0
def get_starred_with_dates(named_user):
    """
    :calls: `GET /users/:user/starred <http://developer.github.com/v3/activity/starring>`_
    :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`Starred`
    """
    return PaginatedList.PaginatedList(
        Starred,
        named_user._requester,
        named_user.url + "/starred",
        None,
        headers={'Accept': Consts.mediaTypeStarringPreview})
Exemplo n.º 4
0
def main():
    inputs = ActionsContext("input")
    context = ActionsContext("github")

    debug = False
    if hasattr(inputs, 'debug'):
        if inputs.debug.lower() in ['true', 'yes', '1']:
            debug = True

    repo = Github(inputs.access_token).get_repo(context.repository)

    current_run_id = int(context.run_id)
    current_created_at = repo.get_workflow_run(current_run_id).created_at

    if context.event_name == "pull_request":
        current_branch = context.head_ref
    else:
        current_branch = context.ref.replace("refs/heads/", "")

    # Kinda hacky.
    runs_queued = PaginatedList.PaginatedList(
        WorkflowRun.WorkflowRun,
        repo._requester,
        repo.url + "/actions/runs",
        {
            "branch": current_branch,
            "status": "queued"
        },
        list_item="workflow_runs",
    )
    runs_in_progress = PaginatedList.PaginatedList(
        WorkflowRun.WorkflowRun,
        repo._requester,
        repo.url + "/actions/runs",
        {
            "branch": current_branch,
            "status": "in_progress"
        },
        list_item="workflow_runs",
    )

    if debug:
        print("Candidates for cancellation: ")
        for i in runs_queued:
            print(i)
        for i in runs_in_progress:
            print(i)

    runs_to_cancel = []

    for run in runs_queued:
        if run.id != current_run_id and run.created_at <= current_created_at:
            runs_to_cancel.append(run)

    for run in runs_in_progress:
        if run.id != current_run_id and run.created_at <= current_created_at:
            runs_to_cancel.append(run)

    if runs_to_cancel:
        for run in runs_to_cancel:
            print(f"Cancelling run id {run.id}")
            run.cancel()
    else:
        print("No runs to cancel.")
Exemplo n.º 5
0
 def parser_comments(commentList: PaginatedList) -> list:
     comments_info = []
     for comment in commentList.get_page(0):
         comment_info = GithubObjectParser.parser_comment(comment)
         comments_info.append(comment_info)
     return comments_info
        return False


is_removal = get_is_removal()
username = input('👋 Input your GitHub username: '******'🔐 Input your GitHub password: '******'#BlackLivesMatter'

github_api = Github(username, password)
github_user = github_api.get_user()

all_repos = PaginatedList.PaginatedList(
    Repository.Repository,
    github_user._requester,
    f'{github_user.url}/repos',
    dict(
        affiliation='owner',
        visibility='public',
    ),
)


def print_separator():
    print(u'\u2500' * 15)


def if_none_to_string(string, fallback=''):
    return str(string or fallback)


repo_count = 0