Commit 70442fce authored by Emmanuel Arias's avatar Emmanuel Arias

New upstream version 1.43.7

parent 98eb62e9
Metadata-Version: 2.1
Name: PyGithub
Version: 1.43.3
Version: 1.43.7
Summary: Use the full Github API v3
Home-page: http://pygithub.readthedocs.io/en/latest/
Author: Vincent Jacques
......@@ -39,9 +39,9 @@ Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
Provides-Extra: integrations
Metadata-Version: 2.1
Name: PyGithub
Version: 1.43.3
Version: 1.43.7
Summary: Use the full Github API v3
Home-page: http://pygithub.readthedocs.io/en/latest/
Author: Vincent Jacques
......@@ -39,9 +39,9 @@ Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
Provides-Extra: integrations
This diff is collapsed.
requests>=2.14.0
deprecated
pyjwt
Deprecated
requests>=2.14.0
[integrations]
cryptography
......@@ -6,6 +6,7 @@
[![License](https://img.shields.io/badge/license-LGPL-blue.svg)](https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License)
[![Join the chat at https://gitter.im/PyGithub/PyGithub](https://badges.gitter.im/PyGithub/PyGithub.svg)](https://gitter.im/PyGithub/PyGithub?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Open Source Helpers](https://www.codetriage.com/pygithub/pygithub/badges/users.svg)](https://www.codetriage.com/pygithub/pygithub)
[![codecov](https://codecov.io/gh/PyGithub/PyGithub/branch/master/graph/badge.svg)](https://codecov.io/gh/PyGithub/PyGithub)
PyGitHub is a Python (2 and 3) library to access the [GitHub API v3] and [Github Enterprise API v3].
This library enables you to manage [GitHub] resources such as repositories, user profiles, and organizations in your Python applications.
......
......@@ -55,6 +55,7 @@ import github.Issue
import github.Event
import github.Authorization
import github.Notification
import github.Migration
import Consts
......@@ -237,6 +238,14 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._completeIfNotSet(self._name)
return self._name.value
@property
def node_id(self):
"""
:type: string
"""
self._completeIfNotSet(self._node_id)
return self._node_id.value
@property
def organizations_url(self):
"""
......@@ -486,7 +495,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description
post_parameters = {
"public": public,
"files": dict((key, value._identity) for key, value in files.iteritems()),
"files": {key: value._identity for key, value in files.iteritems()},
}
if description is not github.GithubObject.NotSet:
post_parameters["description"] = description
......@@ -835,23 +844,30 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
)
return github.Notification.Notification(self._requester, headers, data, completed=True)
def get_notifications(self, all=github.GithubObject.NotSet, participating=github.GithubObject.NotSet):
def get_notifications(self, all=github.GithubObject.NotSet, participating=github.GithubObject.NotSet, since=github.GithubObject.NotSet, before=github.GithubObject.NotSet):
"""
:calls: `GET /notifications <http://developer.github.com/v3/activity/notifications>`_
:param all: bool
:param participating: bool
:param since: datetime.datetime
:param before: datetime.datetime
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Notification.Notification`
"""
assert all is github.GithubObject.NotSet or isinstance(all, bool), all
assert participating is github.GithubObject.NotSet or isinstance(participating, bool), participating
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
assert before is github.GithubObject.NotSet or isinstance(before, datetime.datetime), before
params = dict()
if all is not github.GithubObject.NotSet:
params["all"] = all
if participating is not github.GithubObject.NotSet:
params["participating"] = participating
# TODO: implement parameter "since"
if since is not github.GithubObject.NotSet:
params["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
if before is not github.GithubObject.NotSet:
params["before"] = before.strftime("%Y-%m-%dT%H:%M:%SZ")
return github.PaginatedList.PaginatedList(
github.Notification.Notification,
......@@ -1139,6 +1155,50 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
input={}
)
def create_migration(self, repos, lock_repositories=github.GithubObject.NotSet, exclude_attachments=github.GithubObject.NotSet):
"""
:calls: `POST /user/migrations`_
:param repos: list or tuple of str
:param lock_repositories: bool
:param exclude_attachments: bool
:rtype: :class:`github.Migration.Migration`
"""
assert isinstance(repos, (list, tuple)), repos
assert all(isinstance(repo, (str, unicode)) for repo in repos), repos
assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories
assert exclude_attachments is github.GithubObject.NotSet or isinstance(exclude_attachments, bool), exclude_attachments
post_parameters = {
"repositories": repos
}
if lock_repositories is not github.GithubObject.NotSet:
post_parameters["lock_repositories"] = lock_repositories
if exclude_attachments is not github.GithubObject.NotSet:
post_parameters["exclude_attachments"] = exclude_attachments
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/user/migrations",
input=post_parameters,
headers={
"Accept": Consts.mediaTypeMigrationPreview
}
)
return github.Migration.Migration(self._requester, headers, data, completed=True)
def get_migrations(self):
"""
:calls: `GET /user/migrations`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Migration.Migration`
"""
return github.PaginatedList.PaginatedList(
github.Migration.Migration,
self._requester,
"/user/migrations",
None,
headers={
"Accept": Consts.mediaTypeMigrationPreview
}
)
def _initAttributes(self):
self._avatar_url = github.GithubObject.NotSet
self._bio = github.GithubObject.NotSet
......@@ -1161,6 +1221,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._location = github.GithubObject.NotSet
self._login = github.GithubObject.NotSet
self._name = github.GithubObject.NotSet
self._node_id = github.GithubObject.NotSet
self._organizations_url = github.GithubObject.NotSet
self._owned_private_repos = github.GithubObject.NotSet
self._plan = github.GithubObject.NotSet
......@@ -1220,6 +1281,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._login = self._makeStringAttribute(attributes["login"])
if "name" in attributes: # pragma no branch
self._name = self._makeStringAttribute(attributes["name"])
if "node_id" in attributes: # pragma no branch
self._node_id = self._makeStringAttribute(attributes["node_id"])
if "organizations_url" in attributes: # pragma no branch
self._organizations_url = self._makeStringAttribute(attributes["organizations_url"])
if "owned_private_repos" in attributes: # pragma no branch
......
......@@ -2,12 +2,11 @@
############################ Copyrights and license ############################
# #
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
# Copyright 2018 sfdye <tsfdye@gmail.com> #
# Copyright 2018 Justin Kufro <jkufro@andrew.cmu.edu> #
# Copyright 2018 Ivan Minno <iminno@andrew.cmu.edu> #
# Copyright 2018 Zilei Gu <zileig@andrew.cmu.edu> #
# Copyright 2018 Yves Zumbach <yzumbach@andrew.cmu.edu> #
# Copyright 2018 Leying Chen <leyingc@andrew.cmu.edu> #
# #
# This file is part of PyGithub. #
# http://pygithub.readthedocs.io/ #
......@@ -30,34 +29,49 @@
import github.GithubObject
class Status(github.GithubObject.NonCompletableGithubObject):
class Clones(github.GithubObject.NonCompletableGithubObject):
"""
This class represents Statuses. The reference can be found here https://status.github.com/api
This class represents a popular Path for a GitHub repository.
The reference can be found here https://developer.github.com/v3/repos/traffic/
"""
def __repr__(self):
return self.get__repr__({"status": self._status.value})
return self.get__repr__({
"timestamp": self._timestamp.value,
"count": self._count.value,
"uniques": self._uniques.value
})
@property
def status(self):
def timestamp(self):
"""
:type: string
:type: datetime.datetime
"""
return self._status.value
return self._timestamp.value
@property
def last_updated(self):
def count(self):
"""
:type: datetime.datetime
:type: integer
"""
return self._count.value
@property
def uniques(self):
"""
:type: integer
"""
return self._last_updated.value
return self._uniques.value
def _initAttributes(self):
self._status = github.GithubObject.NotSet
self._last_updated = github.GithubObject.NotSet
self._timestamp = github.GithubObject.NotSet
self._count = github.GithubObject.NotSet
self._uniques = github.GithubObject.NotSet
def _useAttributes(self, attributes):
if "status" in attributes: # pragma no branch
self._status = self._makeStringAttribute(attributes["status"])
if "last_updated" in attributes: # pragma no branch
self._last_updated = self._makeDatetimeAttribute(attributes["last_updated"])
if "timestamp" in attributes: # pragma no branch
self._timestamp = self._makeDatetimeAttribute(attributes["timestamp"])
if "count" in attributes: # pragma no branch
self._count = self._makeIntAttribute(attributes["count"])
if "uniques" in attributes: # pragma no branch
self._uniques = self._makeIntAttribute(attributes["uniques"])
......@@ -48,6 +48,7 @@ RES_LAST_MODIFIED = "last-modified"
headerRateLimit = "x-ratelimit-limit"
headerRateRemaining = "x-ratelimit-remaining"
headerRateReset = "x-ratelimit-reset"
headerOAuthScopes = "x-oauth-scopes"
headerOTP = "X-GitHub-OTP"
defaultMediaType = "application/octet-stream"
......@@ -90,6 +91,9 @@ mediaTypeOrganizationInvitationPreview = "application/vnd.github.dazzler-preview
# https://developer.github.com/changes/2018-03-16-protected-branches-required-approving-reviews/
mediaTypeRequireMultipleApprovingReviews = "application/vnd.github.luke-cage-preview+json"
# https://developer.github.com/changes/2018-05-24-user-migration-api/
mediaTypeMigrationPreview = "application/vnd.github.wyandotte-preview+json"
# https://developer.github.com/v3/search/#highlighting-code-search-results-1
highLightSearchPreview = "application/vnd.github.v3.text-match+json"
......
......@@ -253,7 +253,7 @@ class Gist(github.GithubObject.CompletableGithubObject):
if description is not github.GithubObject.NotSet:
post_parameters["description"] = description
if files is not github.GithubObject.NotSet:
post_parameters["files"] = dict((key, None if value is None else value._identity) for key, value in files.iteritems())
post_parameters["files"] = {key: None if value is None else value._identity for key, value in files.iteritems()}
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.url,
......
......@@ -37,7 +37,7 @@
from os.path import basename
import github.GithubObject
import github.GitAuthor
import github.NamedUser
import github.GitReleaseAsset
......@@ -108,7 +108,7 @@ class GitRelease(github.GithubObject.CompletableGithubObject):
@property
def author(self):
"""
:type: :class:`github.GitAuthor.GitAuthor`
:type: :class:`github.NamedUser.NamedUser`
"""
self._completeIfNotSet(self._author)
return self._author.value
......@@ -285,7 +285,7 @@ class GitRelease(github.GithubObject.CompletableGithubObject):
if "prerelease" in attributes:
self._prerelease = self._makeBoolAttribute(attributes["prerelease"])
if "author" in attributes:
self._author = self._makeClassAttribute(github.GitAuthor.GitAuthor, attributes["author"])
self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"])
if "url" in attributes:
self._url = self._makeStringAttribute(attributes["url"])
if "upload_url" in attributes:
......
......@@ -170,7 +170,7 @@ class GithubObject(object):
# The Downloads API has been removed. I'm keeping this branch because I have no mean
# to check if it's really useless now.
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%S.000Z") # pragma no cover (This branch was used only when creating a download)
elif len(s) == 25:
elif len(s) >= 25:
return datetime.datetime.strptime(s[:19], "%Y-%m-%dT%H:%M:%S") + (1 if s[19] == '-' else -1) * datetime.timedelta(hours=int(s[20:22]), minutes=int(s[23:25]))
else:
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ")
......
......@@ -53,10 +53,11 @@ import urllib
import pickle
import time
import sys
from httplib import HTTPSConnection
import requests
import jwt
import urllib3
from Requester import Requester, json
from Requester import Requester
import AuthenticatedUser
import NamedUser
import Organization
......@@ -66,11 +67,10 @@ import Repository
import Installation
import Legacy
import License
import Topic
import github.GithubObject
import HookDescription
import GitignoreTemplate
import Status
import StatusMessage
import RateLimit
import InstallationAuthorization
import GithubException
......@@ -94,7 +94,7 @@ class Github(object):
This is the main class you instantiate to access the Github API v3. Optional parameters allow different authentication methods.
"""
def __init__(self, login_or_token=None, password=None, jwt=None, base_url=DEFAULT_BASE_URL, timeout=DEFAULT_TIMEOUT, client_id=None, client_secret=None, user_agent='PyGithub/Python', per_page=DEFAULT_PER_PAGE, api_preview=False, verify=True):
def __init__(self, login_or_token=None, password=None, jwt=None, base_url=DEFAULT_BASE_URL, timeout=DEFAULT_TIMEOUT, client_id=None, client_secret=None, user_agent='PyGithub/Python', per_page=DEFAULT_PER_PAGE, api_preview=False, verify=True, retry=None):
"""
:param login_or_token: string
:param password: string
......@@ -105,6 +105,7 @@ class Github(object):
:param user_agent: string
:param per_page: int
:param verify: boolean or string
:param retry: int or urllib3.util.retry.Retry object
"""
assert login_or_token is None or isinstance(login_or_token, (str, unicode)), login_or_token
......@@ -116,7 +117,8 @@ class Github(object):
assert client_secret is None or isinstance(client_secret, (str, unicode)), client_secret
assert user_agent is None or isinstance(user_agent, (str, unicode)), user_agent
assert isinstance(api_preview, (bool))
self.__requester = Requester(login_or_token, password, jwt, base_url, timeout, client_id, client_secret, user_agent, per_page, api_preview, verify)
assert retry is None or isinstance(retry, (int)) or isinstance(retry, (urllib3.util.Retry))
self.__requester = Requester(login_or_token, password, jwt, base_url, timeout, client_id, client_secret, user_agent, per_page, api_preview, verify, retry)
def __get_FIX_REPO_GET_GIT_REF(self):
"""
......@@ -542,7 +544,7 @@ class Github(object):
:calls: `GET /search/topics <http://developer.github.com/v3/search>`_
:param query: string
:param qualifiers: keyword dict query qualifiers
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Topic.Topic`
"""
assert isinstance(query, (str, unicode)), query
url_parameters = dict()
......@@ -558,7 +560,7 @@ class Github(object):
assert url_parameters["q"], "need at least one qualifier"
return github.PaginatedList.PaginatedList(
github.Repository.Repository,
github.Topic.Topic,
self.__requester,
"/search/topics",
url_parameters,
......@@ -680,45 +682,6 @@ class Github(object):
"""
return self.create_from_raw_data(*pickle.load(f))
def get_api_status(self):
"""
This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com.