mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
De-hard-code repository in RepositoryKey.
Why is RepositoryKey the *only* class where PATCH and DELETE do not work on self.url?
This commit is contained in:
@@ -344,7 +344,7 @@ class Repository( object ):
|
||||
None,
|
||||
post_parameters
|
||||
)
|
||||
return RepositoryKey.RepositoryKey( self.__requester, data, completion = NoCompletion )
|
||||
return RepositoryKey.RepositoryKey( self.__requester, data, completion = NoCompletion, repoUrl = self.url )
|
||||
|
||||
def create_label( self, name, color ):
|
||||
post_parameters = {
|
||||
@@ -697,7 +697,7 @@ class Repository( object ):
|
||||
None,
|
||||
None
|
||||
)
|
||||
return RepositoryKey.RepositoryKey( self.__requester, data, completion = NoCompletion )
|
||||
return RepositoryKey.RepositoryKey( self.__requester, data, completion = NoCompletion, repoUrl = self.url )
|
||||
|
||||
def get_keys( self ):
|
||||
status, headers, data = self.__requester.request(
|
||||
@@ -707,7 +707,7 @@ class Repository( object ):
|
||||
None
|
||||
)
|
||||
return PaginatedList.PaginatedList(
|
||||
RepositoryKey.RepositoryKey,
|
||||
lambda r, d, completion: RepositoryKey.RepositoryKey( r, d, completion, repoUrl = self.url ),
|
||||
self.__requester,
|
||||
headers,
|
||||
data
|
||||
|
||||
@@ -5,13 +5,18 @@ import PaginatedList
|
||||
from GithubObject import *
|
||||
|
||||
class RepositoryKey( object ):
|
||||
def __init__( self, requester, attributes, completion ):
|
||||
def __init__( self, requester, attributes, completion, repoUrl ):
|
||||
self.__requester = requester
|
||||
self.__initAttributes()
|
||||
self.__useAttributes( attributes )
|
||||
self.__completed = completion != LazyCompletion
|
||||
if completion == ImmediateCompletion:
|
||||
self.__complete() # pragma: no cover
|
||||
self.__repoUrl = repoUrl
|
||||
|
||||
@property
|
||||
def __customUrl( self ):
|
||||
return self.__repoUrl + "/keys/" + str( self.id )
|
||||
|
||||
@property
|
||||
def id( self ):
|
||||
@@ -41,7 +46,7 @@ class RepositoryKey( object ):
|
||||
def delete( self ):
|
||||
status, headers, data = self.__requester.request(
|
||||
"DELETE",
|
||||
"https://api.github.com/repos/jacquev6/PyGithub/keys/2626761",
|
||||
self.__customUrl,
|
||||
None,
|
||||
None
|
||||
)
|
||||
@@ -55,7 +60,7 @@ class RepositoryKey( object ):
|
||||
post_parameters[ "key" ] = key
|
||||
status, headers, data = self.__requester.request(
|
||||
"PATCH",
|
||||
"https://api.github.com/repos/jacquev6/PyGithub/keys/2626761",
|
||||
self.__customUrl,
|
||||
None,
|
||||
post_parameters
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user