mirror of
				https://github.com/RGBCube/GitHubWrapper
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	Fixed getpass and del dying
This commit is contained in:
		
							parent
							
								
									153e1e50d4
								
							
						
					
					
						commit
						ebd9828afa
					
				
					 1 changed files with 12 additions and 8 deletions
				
			
		|  | @ -1,17 +1,18 @@ | |||
| #== main.py ==# | ||||
| 
 | ||||
| __all__ = ( | ||||
|     'Github', | ||||
|     'GHClient', | ||||
| ) | ||||
| 
 | ||||
| from getpass import getpass | ||||
| import aiohttp | ||||
| import asyncio | ||||
| 
 | ||||
| import http | ||||
| import exceptions | ||||
| from objects import User, Repository | ||||
| from . import http | ||||
| from . import exceptions | ||||
| from .objects import User, Repository | ||||
| 
 | ||||
| class Github: | ||||
| class GHClient: | ||||
|     _auth = None | ||||
|     has_started = False | ||||
|     def __init__( | ||||
|  | @ -24,15 +25,18 @@ class Github: | |||
|         self._headers = custom_headers | ||||
|         if using_auth: | ||||
|             username = input('Enter your username: ') #these two lines are blocking, but it's probably not a problem | ||||
|             auth_token = getpass.getpass('Enter your token: ') | ||||
|             auth_token = getpass('Enter your token: ') | ||||
|             self._auth = aiohttp.BasicAuth(username, auth_token) | ||||
| 
 | ||||
|     def __await__(self): | ||||
|     def __await__(self) -> 'GHClient': | ||||
|         return self.start().__await__() | ||||
| 
 | ||||
|     def __repr__(self) -> str: | ||||
|         return f'<Github Client; has_auth={bool(self._auth)}>' | ||||
| 
 | ||||
|     def __del__(self): | ||||
|         asyncio.create_task(self.session.close()) | ||||
| 
 | ||||
|     def check_limits(self, as_dict: bool = False) -> dict[str, str | int] | list[str]: | ||||
|         if not self.has_started: | ||||
|             raise exceptions.NotStarted | ||||
|  | @ -49,7 +53,7 @@ class Github: | |||
|         token = getpass('Enter your token: ') | ||||
|         self._auth = aiohttp.BasicAuth(username, token) | ||||
| 
 | ||||
|     async def start(self) -> None: | ||||
|     async def start(self) -> 'GHClient': | ||||
|         """Main entry point to the wrapper, this creates the ClientSession.""" | ||||
|         if self.has_started: | ||||
|             raise exceptions.AlreadyStarted | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 sudosnok
						sudosnok