diff --git a/Github/main.py b/Github/main.py index 493d936..9ac8509 100644 --- a/Github/main.py +++ b/Github/main.py @@ -7,28 +7,13 @@ __all__ = ( import asyncio import functools -import io import aiohttp from . import exceptions from .cache import RepoCache, UserCache from .http import http -from .objects import Gist, Issue, Organization, Repository, User - - -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() +from .objects import Gist, Issue, Organization, Repository, User, File class GHClient: diff --git a/Github/objects.py b/Github/objects.py index 59560e7..f20a07b 100644 --- a/Github/objects.py +++ b/Github/objects.py @@ -7,6 +7,7 @@ if TYPE_CHECKING: from .http import http from datetime import datetime +import io __all__ = ( 'APIObject', @@ -16,6 +17,7 @@ __all__ = ( 'User', 'Repository', 'Issue', + 'File', 'Gist', 'Organization', ) @@ -214,6 +216,19 @@ class Issue(APIObject): #=== 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): __slots__ = ( 'id',