mirror of
				https://github.com/RGBCube/GitHubWrapper
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	Moved File to objects
This commit is contained in:
		
							parent
							
								
									6483909960
								
							
						
					
					
						commit
						a181273189
					
				
					 2 changed files with 16 additions and 16 deletions
				
			
		|  | @ -7,28 +7,13 @@ __all__ = ( | ||||||
| 
 | 
 | ||||||
| import asyncio | import asyncio | ||||||
| import functools | import functools | ||||||
| import io |  | ||||||
| 
 | 
 | ||||||
| import aiohttp | import aiohttp | ||||||
| 
 | 
 | ||||||
| from . import exceptions | from . import exceptions | ||||||
| from .cache import RepoCache, UserCache | from .cache import RepoCache, UserCache | ||||||
| from .http import http | from .http import http | ||||||
| from .objects import Gist, Issue, Organization, Repository, User | from .objects import Gist, Issue, Organization, Repository, User, File | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| class File: |  | ||||||
|     def __init__(self, fp: str | io.StringIO, filename: str = 'DefaultFilename.txt'): |  | ||||||
|         self.fp = fp |  | ||||||
|         self.filename = filename |  | ||||||
| 
 |  | ||||||
|     def read(self) -> str: |  | ||||||
|         if isinstance(self.fp, str): |  | ||||||
|             with open(self.fp) as fp: |  | ||||||
|                 data = fp.read() |  | ||||||
|             return data |  | ||||||
|         else: |  | ||||||
|             return self.fp.read() |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class GHClient: | class GHClient: | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ if TYPE_CHECKING: | ||||||
|     from .http import http |     from .http import http | ||||||
| 
 | 
 | ||||||
| from datetime import datetime | from datetime import datetime | ||||||
|  | import io | ||||||
| 
 | 
 | ||||||
| __all__ = ( | __all__ = ( | ||||||
|     'APIObject', |     'APIObject', | ||||||
|  | @ -16,6 +17,7 @@ __all__ = ( | ||||||
|     'User', |     'User', | ||||||
|     'Repository', |     'Repository', | ||||||
|     'Issue', |     'Issue', | ||||||
|  |     'File', | ||||||
|     'Gist', |     'Gist', | ||||||
|     'Organization', |     'Organization', | ||||||
| ) | ) | ||||||
|  | @ -214,6 +216,19 @@ class Issue(APIObject): | ||||||
| 
 | 
 | ||||||
| #=== Gist stuff ===# | #=== Gist stuff ===# | ||||||
| 
 | 
 | ||||||
|  | class File: | ||||||
|  |     def __init__(self, fp: str | io.StringIO, filename: str = 'DefaultFilename.txt'): | ||||||
|  |         self.fp = fp | ||||||
|  |         self.filename = filename | ||||||
|  | 
 | ||||||
|  |     def read(self) -> str: | ||||||
|  |         if isinstance(self.fp, str): | ||||||
|  |             with open(self.fp) as fp: | ||||||
|  |                 data = fp.read() | ||||||
|  |             return data | ||||||
|  |         else: | ||||||
|  |             return self.fp.read() | ||||||
|  | 
 | ||||||
| class Gist(APIObject): | class Gist(APIObject): | ||||||
|     __slots__ = ( |     __slots__ = ( | ||||||
|         'id', |         'id', | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 sudosnok
						sudosnok