desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Optional support for the authenticate header.'
def build_authenticate_header(self, realm=''):
return {'WWW-Authenticate': ('OAuth realm="%s"' % realm)}
'Verify the correct version request for this server.'
def _get_version(self, request):
try: version = request.get_parameter('oauth_version') except: version = VERSION if (version and (version != self.version)): raise Error(('OAuth version %s not supported.' % str(version))) return version
'Figure out the signature with some defaults.'
def _get_signature_method(self, request):
try: signature_method = request.get_parameter('oauth_signature_method') except: signature_method = SIGNATURE_METHOD try: signature_method = self.signature_methods[signature_method] except: signature_method_names = ', '.join(self.signature_methods.keys()) raise ...
'Verify that timestamp is recentish.'
def _check_timestamp(self, timestamp):
timestamp = int(timestamp) now = int(time.time()) lapsed = (now - timestamp) if (lapsed > self.timestamp_threshold): raise Error(('Expired timestamp: given %d and now %s has a greater difference than threshold %d' % (timestamp, now, self.timestamp_threshold...
'Calculates the string that needs to be signed. This method returns a 2-tuple containing the starting key for the signing and the message to be signed. The latter may be used in error messages to help clients debug their software.'
def signing_base(self, request, consumer, token):
raise NotImplementedError
'Returns the signature for the given request, based on the consumer and token also provided. You should use your implementation of `signing_base()` to build the message to sign. Otherwise it may be less useful for debugging.'
def sign(self, request, consumer, token):
raise NotImplementedError
'Returns whether the given signature is the correct signature for the given consumer and token signing the given request.'
def check(self, request, consumer, token, signature):
built = self.sign(request, consumer, token) return (built == signature)
'Builds the base signature string.'
def sign(self, request, consumer, token):
(key, raw) = self.signing_base(request, consumer, token) try: import hashlib hashed = hmac.new(key, raw, hashlib.sha1) except ImportError: import sha hashed = hmac.new(key, raw, sha) return binascii.b2a_base64(hashed.digest())[:(-1)]
'Concatenates the consumer key and secret with the token\'s secret.'
def signing_base(self, request, consumer, token):
sig = ('%s&' % escape(consumer.secret)) if token: sig = (sig + escape(token.secret)) return (sig, sig)
':type: string'
@property def content(self):
self._completeIfNotSet(self._content) return self._content.value
':type: string'
@property def encoding(self):
self._completeIfNotSet(self._encoding) return self._encoding.value
':type: string'
@property def git_url(self):
self._completeIfNotSet(self._git_url) return self._git_url.value
':type: string'
@property def html_url(self):
self._completeIfNotSet(self._html_url) return self._html_url.value
':type: string'
@property def name(self):
self._completeIfNotSet(self._name) return self._name.value
':type: string'
@property def path(self):
self._completeIfNotSet(self._path) return self._path.value
':type: :class:`github.Repository.Repository`'
@property def repository(self):
if (self._repository is github.GithubObject.NotSet): repo_url = '/'.join(self.url.split('/')[:6]) self._repository = github.GithubObject._ValuedAttribute(github.Repository.Repository(self._requester, self._headers, {'url': repo_url}, completed=False)) return self._repository.value
':type: string'
@property def sha(self):
self._completeIfNotSet(self._sha) return self._sha.value
':type: integer'
@property def size(self):
self._completeIfNotSet(self._size) return self._size.value
':type: string'
@property def type(self):
self._completeIfNotSet(self._type) return self._type.value
':type: string'
@property def url(self):
self._completeIfNotSet(self._url) return self._url.value
'The status returned by the Github API'
@property def status(self):
return self.__status
'The (decoded) data returned by the Github API'
@property def data(self):
return self.__data
'The value returned by Github'
@property def actual_value(self):
return self.__actualValue
'The type PyGithub expected'
@property def expected_type(self):
return self.__expectedType
'The exception raised when PyGithub tried to parse the value'
@property def transformation_exception(self):
return self.__transformationException
':type: string'
@property def status(self):
return self._status.value
':type: datetime.datetime'
@property def last_updated(self):
return self._last_updated.value
':type: dict'
@property def raw_data(self):
self._completeIfNeeded() return self._rawData
':type: dict'
@property def raw_headers(self):
self._completeIfNeeded() return self._headers
':type: str'
@property def etag(self):
return self._headers.get(Consts.RES_ETAG)
':type: str'
@property def last_modified(self):
return self._headers.get(Consts.RES_LAST_MODIFED)
'Check and update the object with conditional request :rtype: Boolean value indicating whether the object is changed'
def update(self):
conditionalRequestHeader = dict() if (self.etag is not None): conditionalRequestHeader[Consts.REQ_IF_NONE_MATCH] = self.etag if (self.last_modified is not None): conditionalRequestHeader[Consts.REQ_IF_MODIFIED_SINCE] = self.last_modified (status, responseHeaders, output) = self._requeste...
':type: datetime.datetime'
@property def w(self):
return self._w.value
':type: int'
@property def a(self):
return self._a.value
':type: int'
@property def d(self):
return self._d.value
':type: int'
@property def c(self):
return self._c.value
':type: :class:`github.NamedUser.NamedUser`'
@property def author(self):
return self._author.value
':type: int'
@property def total(self):
return self._total.value
':type: list of :class:`.Week`'
@property def weeks(self):
return self._weeks.value
':type: integer'
@property def comments(self):
self._completeIfNotSet(self._comments) return self._comments.value
':type: string'
@property def comments_url(self):
self._completeIfNotSet(self._comments_url) return self._comments_url.value
':type: string'
@property def commits_url(self):
self._completeIfNotSet(self._commits_url) return self._commits_url.value
':type: datetime.datetime'
@property def created_at(self):
self._completeIfNotSet(self._created_at) return self._created_at.value
':type: string'
@property def description(self):
self._completeIfNotSet(self._description) return self._description.value
':type: dict of string to :class:`github.GistFile.GistFile`'
@property def files(self):
self._completeIfNotSet(self._files) return self._files.value
':type: :class:`github.Gist.Gist`'
@property def fork_of(self):
self._completeIfNotSet(self._fork_of) return self._fork_of.value
':type: list of :class:`github.Gist.Gist`'
@property def forks(self):
self._completeIfNotSet(self._forks) return self._forks.value
':type: string'
@property def forks_url(self):
self._completeIfNotSet(self._forks_url) return self._forks_url.value
':type: string'
@property def git_pull_url(self):
self._completeIfNotSet(self._git_pull_url) return self._git_pull_url.value
':type: string'
@property def git_push_url(self):
self._completeIfNotSet(self._git_push_url) return self._git_push_url.value
':type: list of :class:`github.GistHistoryState.GistHistoryState`'
@property def history(self):
self._completeIfNotSet(self._history) return self._history.value
':type: string'
@property def html_url(self):
self._completeIfNotSet(self._html_url) return self._html_url.value
':type: string'
@property def id(self):
self._completeIfNotSet(self._id) return self._id.value
':type: :class:`github.NamedUser.NamedUser`'
@property def owner(self):
self._completeIfNotSet(self._owner) return self._owner.value
':type: bool'
@property def public(self):
self._completeIfNotSet(self._public) return self._public.value
':type: datetime.datetime'
@property def updated_at(self):
self._completeIfNotSet(self._updated_at) return self._updated_at.value
':type: string'
@property def url(self):
self._completeIfNotSet(self._url) return self._url.value
':type: :class:`github.NamedUser.NamedUser`'
@property def user(self):
self._completeIfNotSet(self._user) return self._user.value
':calls: `POST /gists/:gist_id/comments <http://developer.github.com/v3/gists/comments>`_ :param body: string :rtype: :class:`github.GistComment.GistComment`'
def create_comment(self, body):
assert isinstance(body, (str, unicode)), body post_parameters = {'body': body} (headers, data) = self._requester.requestJsonAndCheck('POST', (self.url + '/comments'), input=post_parameters) return github.GistComment.GistComment(self._requester, headers, data, completed=True)
':calls: `POST /gists/:id/forks <http://developer.github.com/v3/gists>`_ :rtype: :class:`github.Gist.Gist`'
def create_fork(self):
(headers, data) = self._requester.requestJsonAndCheck('POST', (self.url + '/forks')) return Gist(self._requester, headers, data, completed=True)
':calls: `DELETE /gists/:id <http://developer.github.com/v3/gists>`_ :rtype: None'
def delete(self):
(headers, data) = self._requester.requestJsonAndCheck('DELETE', self.url)
':calls: `PATCH /gists/:id <http://developer.github.com/v3/gists>`_ :param description: string :param files: dict of string to :class:`github.InputFileContent.InputFileContent` :rtype: None'
def edit(self, description=github.GithubObject.NotSet, files=github.GithubObject.NotSet):
assert ((description is github.GithubObject.NotSet) or isinstance(description, (str, unicode))), description assert ((files is github.GithubObject.NotSet) or all((((element is None) or isinstance(element, github.InputFileContent)) for element in files.itervalues()))), files post_parameters = dict() if (...
':calls: `GET /gists/:gist_id/comments/:id <http://developer.github.com/v3/gists/comments>`_ :param id: integer :rtype: :class:`github.GistComment.GistComment`'
def get_comment(self, id):
assert isinstance(id, (int, long)), id (headers, data) = self._requester.requestJsonAndCheck('GET', ((self.url + '/comments/') + str(id))) return github.GistComment.GistComment(self._requester, headers, data, completed=True)
':calls: `GET /gists/:gist_id/comments <http://developer.github.com/v3/gists/comments>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GistComment.GistComment`'
def get_comments(self):
return github.PaginatedList.PaginatedList(github.GistComment.GistComment, self._requester, (self.url + '/comments'), None)
':calls: `GET /gists/:id/star <http://developer.github.com/v3/gists>`_ :rtype: bool'
def is_starred(self):
(status, headers, data) = self._requester.requestJson('GET', (self.url + '/star')) return (status == 204)
':calls: `DELETE /gists/:id/star <http://developer.github.com/v3/gists>`_ :rtype: None'
def reset_starred(self):
(headers, data) = self._requester.requestJsonAndCheck('DELETE', (self.url + '/star'))
':calls: `PUT /gists/:id/star <http://developer.github.com/v3/gists>`_ :rtype: None'
def set_starred(self):
(headers, data) = self._requester.requestJsonAndCheck('PUT', (self.url + '/star'))
':type: datetime.datetime'
@property def week(self):
return self._week.value
':type: int'
@property def total(self):
return self._total.value
':type: list of int'
@property def days(self):
return self._days.value
':type: string'
@property def name(self):
self._completeIfNotSet(self._name) return self._name.value
':type: string'
@property def url(self):
self._completeIfNotSet(self._url) return self._url.value
':type: integer'
@property def closed_issues(self):
self._completeIfNotSet(self._closed_issues) return self._closed_issues.value
':type: datetime.datetime'
@property def created_at(self):
self._completeIfNotSet(self._created_at) return self._created_at.value
':type: :class:`github.NamedUser.NamedUser`'
@property def creator(self):
self._completeIfNotSet(self._creator) return self._creator.value
':type: string'
@property def description(self):
self._completeIfNotSet(self._description) return self._description.value
':type: datetime.datetime'
@property def due_on(self):
self._completeIfNotSet(self._due_on) return self._due_on.value
':type: integer'
@property def id(self):
self._completeIfNotSet(self._id) return self._id.value
':type: string'
@property def labels_url(self):
self._completeIfNotSet(self._labels_url) return self._labels_url.value
':type: integer'
@property def number(self):
self._completeIfNotSet(self._number) return self._number.value
':type: integer'
@property def open_issues(self):
self._completeIfNotSet(self._open_issues) return self._open_issues.value
':type: string'
@property def state(self):
self._completeIfNotSet(self._state) return self._state.value
':type: string'
@property def title(self):
self._completeIfNotSet(self._title) return self._title.value
':type: datetime.datetime'
@property def updated_at(self):
self._completeIfNotSet(self._updated_at) return self._updated_at.value
':type: string'
@property def url(self):
self._completeIfNotSet(self._url) return self._url.value
':calls: `DELETE /repos/:owner/:repo/milestones/:number <http://developer.github.com/v3/issues/milestones>`_ :rtype: None'
def delete(self):
(headers, data) = self._requester.requestJsonAndCheck('DELETE', self.url)
':calls: `PATCH /repos/:owner/:repo/milestones/:number <http://developer.github.com/v3/issues/milestones>`_ :param title: string :param state: string :param description: string :param due_on: date :rtype: None'
def edit(self, title, state=github.GithubObject.NotSet, description=github.GithubObject.NotSet, due_on=github.GithubObject.NotSet):
assert isinstance(title, (str, unicode)), title assert ((state is github.GithubObject.NotSet) or isinstance(state, (str, unicode))), state assert ((description is github.GithubObject.NotSet) or isinstance(description, (str, unicode))), description assert ((due_on is github.GithubObject.NotSet) or isinst...
':calls: `GET /repos/:owner/:repo/milestones/:number/labels <http://developer.github.com/v3/issues/labels>`_ :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label`'
def get_labels(self):
return github.PaginatedList.PaginatedList(github.Label.Label, self._requester, (self.url + '/labels'), None)
':type: integer'
@property def ahead_by(self):
self._completeIfNotSet(self._ahead_by) return self._ahead_by.value
':type: :class:`github.Commit.Commit`'
@property def base_commit(self):
self._completeIfNotSet(self._base_commit) return self._base_commit.value
':type: integer'
@property def behind_by(self):
self._completeIfNotSet(self._behind_by) return self._behind_by.value
':type: list of :class:`github.Commit.Commit`'
@property def commits(self):
self._completeIfNotSet(self._commits) return self._commits.value
':type: string'
@property def diff_url(self):
self._completeIfNotSet(self._diff_url) return self._diff_url.value
':type: list of :class:`github.File.File`'
@property def files(self):
self._completeIfNotSet(self._files) return self._files.value
':type: string'
@property def html_url(self):
self._completeIfNotSet(self._html_url) return self._html_url.value
':type: :class:`github.Commit.Commit`'
@property def merge_base_commit(self):
self._completeIfNotSet(self._merge_base_commit) return self._merge_base_commit.value
':type: string'
@property def patch_url(self):
self._completeIfNotSet(self._patch_url) return self._patch_url.value
':type: string'
@property def permalink_url(self):
self._completeIfNotSet(self._permalink_url) return self._permalink_url.value
':type: string'
@property def status(self):
self._completeIfNotSet(self._status) return self._status.value
':type: integer'
@property def total_commits(self):
self._completeIfNotSet(self._total_commits) return self._total_commits.value