mirror of
				https://github.com/RGBCube/GitHubWrapper
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	Fix files
This commit is contained in:
		
							parent
							
								
									71901dce4b
								
							
						
					
					
						commit
						f75886bc92
					
				
					 2 changed files with 13 additions and 5 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -4,7 +4,7 @@ __pycache__/ | |||
| *$py.class | ||||
| 
 | ||||
| #var is weird | ||||
| test.py | ||||
| test*.py | ||||
| .vscode/ | ||||
| 
 | ||||
| # C extensions | ||||
|  |  | |||
|  | @ -8,6 +8,8 @@ if TYPE_CHECKING: | |||
| 
 | ||||
| from datetime import datetime | ||||
| import io | ||||
| import os | ||||
| from contextlib import nullcontext | ||||
| 
 | ||||
| __all__ = ( | ||||
|     'APIObject', | ||||
|  | @ -220,11 +222,17 @@ class File: | |||
| 
 | ||||
|     def read(self) -> str: | ||||
|         if isinstance(self.fp, str): | ||||
|             with open(self.fp) as fp: | ||||
|                 data = fp.read() | ||||
|             return data | ||||
|             if os.path.exists(self.fp): | ||||
|                 with open(self.fp) as fp: | ||||
|                     data = fp.read() | ||||
|                 return data | ||||
|             return self.fp | ||||
|         elif isinstance(self.fp, io.BytesIO): | ||||
|             return self.fp.read().decode('utf-8') | ||||
|         elif isinstance(self.fp, io.StringIO): | ||||
|             return self.fp.getvalue() | ||||
|         else: | ||||
|             return self.fp.read() | ||||
|           raise TypeError(f'Expected str, io.StringIO, or io.BytesIO, got {type(self.fp)}') | ||||
| 
 | ||||
| class Gist(APIObject): | ||||
|     __slots__ = ( | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 VarMonke
						VarMonke