mirror of
				https://github.com/RGBCube/GitHubWrapper
				synced 2025-10-31 05:52:45 +00:00 
			
		
		
		
	Mangle token
This commit is contained in:
		
							parent
							
								
									15b3546e27
								
							
						
					
					
						commit
						72bd647c9b
					
				
					 3 changed files with 15 additions and 11 deletions
				
			
		|  | @ -74,14 +74,14 @@ class GHClient: | |||
| 
 | ||||
|         if username and token: | ||||
|             self.username = username | ||||
|             self.token = token | ||||
|             self._auth = aiohttp.BasicAuth(username, token) | ||||
|             self.__token = token | ||||
|             self.__auth = aiohttp.BasicAuth(username, token) | ||||
|         else: | ||||
|             self._auth = None | ||||
|             self.__auth = None | ||||
|             self.username = None | ||||
|             self.token = None | ||||
|             self.__token = None | ||||
| 
 | ||||
|         self.http = http(headers=custom_headers, auth=self._auth) | ||||
|         self.http = http(headers=custom_headers, auth=self.__auth) | ||||
| 
 | ||||
|         self._user_cache = ObjectCache[Any, User](user_cache_size) | ||||
|         self._repo_cache = ObjectCache[Any, Repository](repo_cache_size) | ||||
|  | @ -109,7 +109,7 @@ class GHClient: | |||
|             raise Exception('HTTP Session doesn\'t exist') from exc | ||||
| 
 | ||||
|     def __repr__(self) -> str: | ||||
|         return f'<{self.__class__.__name__} has_auth={bool(self._auth)}>' | ||||
|         return f'<{self.__class__.__name__} has_auth={bool(self.__auth)}>' | ||||
| 
 | ||||
|     @overload | ||||
|     def check_limits(self, as_dict: Literal[True] = True) -> Dict[str, Union[str, int]]: | ||||
|  | @ -167,8 +167,8 @@ class GHClient: | |||
|         """ | ||||
|         if self.has_started: | ||||
|             raise exceptions.AlreadyStarted | ||||
|         if self._auth: | ||||
|             self.http = await http(auth=self._auth, headers=self._headers) | ||||
|         if self.__auth: | ||||
|             self.http = await http(auth=self.__auth, headers=self._headers) | ||||
|             try: | ||||
|                 await self.http.get_self() | ||||
|             except exceptions.InvalidToken as exc: | ||||
|  | @ -213,7 +213,7 @@ class GHClient: | |||
|     # @_cache(type='User') | ||||
|     async def get_self(self) -> User: | ||||
|         """:class:`User`: Returns the authenticated User object.""" | ||||
|         if self._auth: | ||||
|         if self.__auth: | ||||
|             return User(await self.http.get_self(), self.http) | ||||
|         else: | ||||
|             raise exceptions.NoAuthProvided | ||||
|  |  | |||
|  | @ -93,8 +93,8 @@ class InvalidToken(ClientException): | |||
| class InvalidAuthCombination(ClientException): | ||||
|     """Raised when the username and token are both provided.""" | ||||
| 
 | ||||
|     def __init__(self): | ||||
|         msg = 'The username and token cannot be used together.' | ||||
|     def __init__(self, msg: str): | ||||
|         #msg = 'The username and token cannot be used together.' | ||||
|         super().__init__(msg) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -253,6 +253,10 @@ class Repository(APIObject): | |||
|     def forks(self) -> int: | ||||
|         return self._response.get('forks') | ||||
| 
 | ||||
|     async def delete(self) -> None: | ||||
|         """Deletes the repository.""" | ||||
|         return await self._http.delete_repo(self.owner.name, self.name,) #type: ignore | ||||
| 
 | ||||
| 
 | ||||
| class Issue(APIObject): | ||||
|     """Representation of an issue on Github. | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 VarMonke
						VarMonke