mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-05-17 22:45:08 +00:00
Update readthedocs version (might break stuff)
This commit is contained in:
parent
0d10386c39
commit
17b813532d
14 changed files with 67 additions and 70 deletions
|
@ -1,7 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
|
@ -85,7 +85,7 @@ with open('../github/__init__.py') as f:
|
||||||
release = version
|
release = version
|
||||||
|
|
||||||
# This assumes a tag is available for final releases
|
# This assumes a tag is available for final releases
|
||||||
branch = 'master' if version.endswith('a') else 'v' + version
|
branch = 'master' if version.endswith('a') else f"v{version}"
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
import inspect
|
import inspect
|
||||||
import re
|
import re
|
||||||
from typing import Dict, List, NamedTuple, Optional, Tuple, Sequence, TYPE_CHECKING
|
from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Sequence, Tuple
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
|
|
|
@ -42,7 +42,7 @@ class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder):
|
||||||
self.handle_page('genindex-all', genindexcontext, 'genindex.html')
|
self.handle_page('genindex-all', genindexcontext, 'genindex.html')
|
||||||
for (key, entries), count in zip(genindex, indexcounts):
|
for (key, entries), count in zip(genindex, indexcounts):
|
||||||
ctx = {'key': key, 'entries': entries, 'count': count, 'genindexentries': genindex}
|
ctx = {'key': key, 'entries': entries, 'count': count, 'genindexentries': genindex}
|
||||||
self.handle_page('genindex-' + key, ctx, 'genindex-single.html')
|
self.handle_page(f"genindex-{key}", ctx, 'genindex-single.html')
|
||||||
else:
|
else:
|
||||||
self.handle_page('genindex', genindexcontext, 'genindex.html')
|
self.handle_page('genindex', genindexcontext, 'genindex.html')
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from docutils.parsers.rst import Directive
|
|
||||||
from docutils.parsers.rst import states, directives # type: ignore
|
|
||||||
from docutils.parsers.rst.roles import set_classes
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
|
from docutils.parsers.rst import directives # type: ignore
|
||||||
|
from docutils.parsers.rst import Directive
|
||||||
|
from docutils.parsers.rst.roles import set_classes
|
||||||
|
|
||||||
|
|
||||||
class details(nodes.General, nodes.Element):
|
class details(nodes.General, nodes.Element):
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
from docutils.parsers.rst import Directive
|
|
||||||
from docutils.parsers.rst import states, directives # type: ignore
|
|
||||||
from docutils.parsers.rst.roles import set_classes
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from sphinx.locale import _
|
from docutils.parsers.rst import Directive
|
||||||
|
|
||||||
|
|
||||||
class exception_hierarchy(nodes.General, nodes.Element):
|
class exception_hierarchy(nodes.General, nodes.Element):
|
||||||
|
|
|
@ -4,11 +4,10 @@
|
||||||
|
|
||||||
from typing import Any, Dict, List, Tuple
|
from typing import Any, Dict, List, Tuple
|
||||||
|
|
||||||
|
import sphinx
|
||||||
from docutils import nodes, utils
|
from docutils import nodes, utils
|
||||||
from docutils.nodes import Node, system_message
|
from docutils.nodes import Node, system_message
|
||||||
from docutils.parsers.rst.states import Inliner
|
from docutils.parsers.rst.states import Inliner
|
||||||
|
|
||||||
import sphinx
|
|
||||||
from sphinx.application import Sphinx
|
from sphinx.application import Sphinx
|
||||||
from sphinx.util.nodes import split_explicit_title
|
from sphinx.util.nodes import split_explicit_title
|
||||||
from sphinx.util.typing import RoleFunction
|
from sphinx.util.typing import RoleFunction
|
||||||
|
|
|
@ -7,7 +7,7 @@ __license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2022-present VarMonke & sudosnok'
|
__copyright__ = 'Copyright (c) 2022-present VarMonke & sudosnok'
|
||||||
|
|
||||||
from .client import *
|
from .client import *
|
||||||
from .objects import *
|
|
||||||
from .http import *
|
|
||||||
from .urls import *
|
|
||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
|
from .http import *
|
||||||
|
from .objects import *
|
||||||
|
from .urls import *
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from typing import Any, Deque, Tuple, TypeVar, Dict
|
from typing import Any, Deque, Dict, Tuple, TypeVar
|
||||||
|
|
||||||
__all__: Tuple[str, ...] = ('ObjectCache',)
|
__all__: Tuple[str, ...] = ('ObjectCache',)
|
||||||
|
|
||||||
|
|
|
@ -2,29 +2,29 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
from typing import (
|
from typing import (
|
||||||
|
Any,
|
||||||
Awaitable,
|
Awaitable,
|
||||||
Callable,
|
Callable,
|
||||||
Literal,
|
|
||||||
Any,
|
|
||||||
Coroutine,
|
Coroutine,
|
||||||
Dict,
|
Dict,
|
||||||
Generator,
|
Generator,
|
||||||
|
List,
|
||||||
|
Literal,
|
||||||
Optional,
|
Optional,
|
||||||
Tuple,
|
Tuple,
|
||||||
Union,
|
|
||||||
List,
|
|
||||||
overload,
|
|
||||||
TypeVar,
|
TypeVar,
|
||||||
|
Union,
|
||||||
|
overload,
|
||||||
)
|
)
|
||||||
from typing_extensions import Self, ParamSpec, Concatenate
|
|
||||||
|
import aiohttp
|
||||||
|
from typing_extensions import Concatenate, ParamSpec, Self
|
||||||
|
|
||||||
from . import exceptions
|
from . import exceptions
|
||||||
from .cache import ObjectCache
|
from .cache import ObjectCache
|
||||||
from .http import http
|
from .http import http
|
||||||
from .objects import Gist, Issue, Organization, Repository, User, File
|
from .objects import File, Gist, Issue, Organization, Repository, User
|
||||||
|
|
||||||
__all__: Tuple[str, ...] = ('GHClient', 'Client')
|
__all__: Tuple[str, ...] = ('GHClient', 'Client')
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Ratelimited(APIError):
|
||||||
|
|
||||||
def __init__(self, reset_time: datetime.datetime):
|
def __init__(self, reset_time: datetime.datetime):
|
||||||
formatted = reset_time.strftime(r"%H:%M:%S %A, %d %b")
|
formatted = reset_time.strftime(r"%H:%M:%S %A, %d %b")
|
||||||
msg = "We're being ratelimited, wait until {}.\nAuthentication raises the ratelimit.".format(formatted)
|
msg = f"We're being ratelimited, wait until {formatted}.\nAuthentication raises the ratelimit."
|
||||||
super().__init__(msg)
|
super().__init__(msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,21 @@
|
||||||
# == http.py ==#
|
# == http.py ==#
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from asyncio.base_subprocess import ReadSubprocessPipeProto
|
|
||||||
from base64 import b64encode
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
from typing import Any, Dict, Literal, NamedTuple, Optional, Type, Tuple, Union, List
|
from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Type, Union
|
||||||
from typing_extensions import TypeAlias, reveal_type
|
|
||||||
import platform
|
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
from .exceptions import *
|
|
||||||
from .exceptions import GistNotFound, RepositoryAlreadyExists, MissingPermissions
|
|
||||||
from .exceptions import FileAlreadyExists
|
|
||||||
from .exceptions import ResourceAlreadyExists
|
|
||||||
from .exceptions import Ratelimited
|
|
||||||
from .objects import User, Gist, Repository, File, bytes_to_b64
|
|
||||||
from .urls import *
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
|
from .exceptions import *
|
||||||
|
from .objects import File, Gist, Repository, User, bytes_to_b64
|
||||||
|
from .urls import *
|
||||||
|
|
||||||
__all__: Tuple[str, ...] = (
|
__all__: Tuple[str, ...] = (
|
||||||
'Paginator',
|
'Paginator',
|
||||||
|
@ -73,9 +67,10 @@ APIType: TypeAlias = Union[User, Gist, Repository]
|
||||||
async def make_session(*, headers: Dict[str, str], authorization: Union[aiohttp.BasicAuth, None]) -> aiohttp.ClientSession:
|
async def make_session(*, headers: Dict[str, str], authorization: Union[aiohttp.BasicAuth, None]) -> aiohttp.ClientSession:
|
||||||
"""This makes the ClientSession, attaching the trace config and ensuring a UA header is present."""
|
"""This makes the ClientSession, attaching the trace config and ensuring a UA header is present."""
|
||||||
if not headers.get('User-Agent'):
|
if not headers.get('User-Agent'):
|
||||||
headers[
|
headers['User-Agent'] = (
|
||||||
'User-Agent'
|
f'Github-API-Wrapper (https://github.com/VarMonke/Github-Api-Wrapper) @ {__version__} Python'
|
||||||
] = f'Github-API-Wrapper (https://github.com/VarMonke/Github-Api-Wrapper) @ {__version__} Python {platform.python_version()} aiohttp {aiohttp.__version__}'
|
f' {platform.python_version()} aiohttp {aiohttp.__version__}'
|
||||||
|
)
|
||||||
|
|
||||||
session = aiohttp.ClientSession(auth=authorization, headers=headers, trace_configs=[trace_config])
|
session = aiohttp.ClientSession(auth=authorization, headers=headers, trace_configs=[trace_config])
|
||||||
session._rates = Rates('', '', '', '', '')
|
session._rates = Rates('', '', '', '', '')
|
||||||
|
@ -140,9 +135,10 @@ class Paginator:
|
||||||
class http:
|
class http:
|
||||||
def __init__(self, headers: Dict[str, Union[str, int]], auth: Union[aiohttp.BasicAuth, None]) -> None:
|
def __init__(self, headers: Dict[str, Union[str, int]], auth: Union[aiohttp.BasicAuth, None]) -> None:
|
||||||
if not headers.get('User-Agent'):
|
if not headers.get('User-Agent'):
|
||||||
headers[
|
headers['User-Agent'] = (
|
||||||
'User-Agent'
|
'Github-API-Wrapper (https://github.com/VarMonke/Github-Api-Wrapper) @'
|
||||||
] = f'Github-API-Wrapper (https://github.com/VarMonke/Github-Api-Wrapper) @ {__version__} Python/{platform.python_version()} aiohttp/{aiohttp.__version__}'
|
f' {__version__} Python/{platform.python_version()} aiohttp/{aiohttp.__version__}'
|
||||||
|
)
|
||||||
|
|
||||||
self._rates = Rates('', '', '', '', '')
|
self._rates = Rates('', '', '', '', '')
|
||||||
self.headers = headers
|
self.headers = headers
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
# == objects.py ==#
|
# == objects.py ==#
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
import json
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, Literal, Optional, Tuple, Union, Dict, List
|
|
||||||
|
|
||||||
import aiohttp
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .http import http
|
from .http import http
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
__all__: Tuple[str, ...] = (
|
__all__: Tuple[str, ...] = (
|
||||||
'APIObject',
|
'APIObject',
|
||||||
|
@ -201,7 +198,7 @@ class Repository(APIObject):
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'owner',
|
'owner',
|
||||||
'size' 'created_at',
|
'sizecreated_at',
|
||||||
'url',
|
'url',
|
||||||
'html_url',
|
'html_url',
|
||||||
'archived',
|
'archived',
|
||||||
|
@ -346,7 +343,10 @@ class Issue(APIObject):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<{self.__class__.__name__} id: {self.id}, title: {self.title}, user: {self.user}, created_at: {self.created_at}, state: {self.state}>'
|
return (
|
||||||
|
f'<{self.__class__.__name__} id: {self.id}, title: {self.title}, user: {self.user}, created_at:'
|
||||||
|
f' {self.created_at}, state: {self.state}>'
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def updated_at(self) -> Optional[datetime]:
|
def updated_at(self) -> Optional[datetime]:
|
||||||
|
@ -518,7 +518,10 @@ class Organization(APIObject):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'<{self.__class__.__name__} login: {self.login!r}, id: {self.id}, is_verified: {self.is_verified}, public_repos: {self.public_repos}, public_gists: {self.public_gists}, created_at: {self.created_at}>'
|
return (
|
||||||
|
f'<{self.__class__.__name__} login: {self.login!r}, id: {self.id}, is_verified: {self.is_verified},'
|
||||||
|
f' public_repos: {self.public_repos}, public_gists: {self.public_gists}, created_at: {self.created_at}>'
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def description(self):
|
def description(self):
|
||||||
|
|
|
@ -4,40 +4,40 @@ BASE_URL = 'https://api.github.com'
|
||||||
|
|
||||||
|
|
||||||
# == user urls ==#
|
# == user urls ==#
|
||||||
USERS_URL = BASE_URL + '/users/{0}'
|
USERS_URL = f"{BASE_URL}/users/{{0}}"
|
||||||
|
|
||||||
USER_HTML_URL = 'https://github.com/users/{0}'
|
USER_HTML_URL = 'https://github.com/users/{0}'
|
||||||
|
|
||||||
SELF_URL = BASE_URL + '/user'
|
SELF_URL = f"{BASE_URL}/user"
|
||||||
|
|
||||||
USER_REPOS_URL = USERS_URL + '/repos'
|
USER_REPOS_URL = f"{USERS_URL}/repos"
|
||||||
|
|
||||||
USER_ORGS_URL = USERS_URL + '/orgs'
|
USER_ORGS_URL = f"{USERS_URL}/orgs"
|
||||||
|
|
||||||
USER_GISTS_URL = USERS_URL + '/gists'
|
USER_GISTS_URL = f"{USERS_URL}/gists"
|
||||||
|
|
||||||
USER_FOLLOWERS_URL = USERS_URL + '/followers'
|
USER_FOLLOWERS_URL = f"{USERS_URL}/followers"
|
||||||
|
|
||||||
USER_FOLLOWING_URL = USERS_URL + '/following'
|
USER_FOLLOWING_URL = f"{USERS_URL}/following"
|
||||||
|
|
||||||
|
|
||||||
# == repo urls ==#
|
# == repo urls ==#
|
||||||
CREATE_REPO_URL = BASE_URL + '/user/repos' # _auth repo create
|
CREATE_REPO_URL = f"{BASE_URL}/user/repos" # _auth repo create
|
||||||
|
|
||||||
REPOS_URL = BASE_URL + '/repos/{0}' # repos of a user
|
REPOS_URL = f"{BASE_URL}/repos/{{0}}" # repos of a user
|
||||||
|
|
||||||
REPO_URL = BASE_URL + '/repos/{0}/{1}' # a specific repo
|
REPO_URL = f"{BASE_URL}/repos/{{0}}/{{1}}" # a specific repo
|
||||||
|
|
||||||
ADD_FILE_URL = BASE_URL + '/repos/{}/{}/contents/{}'
|
ADD_FILE_URL = f"{BASE_URL}/repos/{{}}/{{}}/contents/{{}}"
|
||||||
|
|
||||||
ADD_FILE_BRANCH = BASE_URL + ''
|
ADD_FILE_BRANCH = f"{BASE_URL}"
|
||||||
|
|
||||||
REPO_ISSUE_URL = REPO_URL + '/issues/{2}' # a specific issue
|
REPO_ISSUE_URL = f"{REPO_URL}/issues/{{2}}" # a specific issue
|
||||||
|
|
||||||
# == gist urls ==#
|
# == gist urls ==#
|
||||||
GIST_URL = BASE_URL + '/gists/{0}' # specific gist
|
GIST_URL = f"{BASE_URL}/gists/{{0}}" # specific gist
|
||||||
|
|
||||||
CREATE_GIST_URL = BASE_URL + '/gists' # create a gist
|
CREATE_GIST_URL = f"{BASE_URL}/gists" # create a gist
|
||||||
|
|
||||||
# == org urls ==#
|
# == org urls ==#
|
||||||
ORG_URL = BASE_URL + '/orgs/{0}'
|
ORG_URL = f"{BASE_URL}/orgs/{{0}}"
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -1,5 +1,6 @@
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
ROOT_DIR = Path(__file__).parent
|
ROOT_DIR = Path(__file__).parent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue