mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
Small no-impact code improvements
This commit is contained in:
+8
-9
@@ -65,21 +65,20 @@ class Requester:
|
||||
|
||||
def requestRaw( self, verb, url, parameters, input ):
|
||||
assert verb in [ "HEAD", "GET", "POST", "PATCH", "PUT", "DELETE" ]
|
||||
|
||||
|
||||
#URLs generated locally will be relative to __base_url
|
||||
#URLs returned from the server will start with __base_url
|
||||
if url.startswith( self.__base_url ):
|
||||
url = url[ len(self.__base_url): ]
|
||||
elif url.startswith( "/" ):
|
||||
url = url
|
||||
else:
|
||||
assert( False ) #pragma no cover
|
||||
|
||||
assert url.startswith( "/" )
|
||||
url = self.__prefix + url
|
||||
|
||||
headers = dict()
|
||||
if self.__authorizationHeader is not None:
|
||||
headers[ "Authorization" ] = self.__authorizationHeader
|
||||
|
||||
cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True, timeout= self.__timeout )
|
||||
cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True, timeout = self.__timeout )
|
||||
cnx.request(
|
||||
verb,
|
||||
self.__completeUrl( url, parameters ),
|
||||
@@ -97,14 +96,14 @@ class Requester:
|
||||
if "x-ratelimit-remaining" in headers and "x-ratelimit-limit" in headers:
|
||||
self.rate_limiting = ( int( headers[ "x-ratelimit-remaining" ] ), int( headers[ "x-ratelimit-limit" ] ) )
|
||||
|
||||
# print verb, url, parameters, input, "==>", status, str( headers )[ :30 ], str( output )[ :30 ]
|
||||
# print verb, self.__base_url + url, parameters, input, "==>", status, str( headers ), str( output )
|
||||
return status, headers, output
|
||||
|
||||
def __completeUrl( self, url, parameters ):
|
||||
if parameters is None or len( parameters ) == 0:
|
||||
return self.__prefix + url
|
||||
return url
|
||||
else:
|
||||
return self.__prefix + url + "?" + urllib.urlencode( parameters )
|
||||
return url + "?" + urllib.urlencode( parameters )
|
||||
|
||||
def __structuredFromJson( self, data ):
|
||||
if len( data ) == 0:
|
||||
|
||||
Reference in New Issue
Block a user