Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solvedac_community/HTTPClients/abstract_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from abc import ABCMeta, abstractmethod
from typing import Optional, Dict

from .httpclient import ResponseData, Route
from solvedac_community.HTTPClients.httpclient import ResponseData, Route


class AbstractHTTPClient(metaclass=ABCMeta):
Expand Down
4 changes: 2 additions & 2 deletions solvedac_community/HTTPClients/aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import aiohttp

from .abstract_http_client import AbstractHTTPClient
from .httpclient import MISSING, ResponseData, Route
from solvedac_community.HTTPClients.abstract_http_client import AbstractHTTPClient
from solvedac_community.HTTPClients.httpclient import MISSING, ResponseData, Route


class AiohttpHTTPClient(AbstractHTTPClient):
Expand Down
8 changes: 4 additions & 4 deletions solvedac_community/HTTPClients/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def get_http_client(
if lib is None:
try:
import aiohttp
from .aiohttp_client import AiohttpHTTPClient
from solvedac_community.HTTPClients.aiohttp_client import AiohttpHTTPClient

return AiohttpHTTPClient(loop, solvedac_token)
except ImportError:
pass

try:
import httpx
from .httpx_client import HttpxHTTPClient
from solvedac_community.HTTPClients.httpx_client import HttpxHTTPClient

return HttpxHTTPClient(loop, solvedac_token)
except ImportError:
Expand All @@ -53,12 +53,12 @@ def get_http_client(
raise ImportError("At least one of aiohttp or httpx libraries is required")

if lib == HTTPClientLibrary.HTTPX:
from .httpx_client import HttpxHTTPClient
from solvedac_community.HTTPClients.httpx_client import HttpxHTTPClient

return HttpxHTTPClient(loop, solvedac_token)

elif lib == HTTPClientLibrary.AIOHTTP:
from .aiohttp_client import AiohttpHTTPClient
from solvedac_community.HTTPClients.aiohttp_client import AiohttpHTTPClient

return AiohttpHTTPClient(loop, solvedac_token)

Expand Down
4 changes: 2 additions & 2 deletions solvedac_community/HTTPClients/httpx_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import httpx

from .abstract_http_client import AbstractHTTPClient
from .httpclient import ResponseData, Route
from solvedac_community.HTTPClients.abstract_http_client import AbstractHTTPClient
from solvedac_community.HTTPClients.httpclient import ResponseData, Route


class HttpxHTTPClient(AbstractHTTPClient):
Expand Down
23 changes: 23 additions & 0 deletions solvedac_community/Schemas/Enums/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

"""
Copyright (c) 2023 DevRuby
MIT License
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""

from .badge_category import BadgeCategory
from .badge_tier import BadgeTier
from .class_decoration import ClassDecoration
from .price_unit import PriceUnit
from .problem_level import ProblemLevel
from .sort_direction import SortDirection
from .sort_type import SortType
from .user_tier import UserTier
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@
OTHER DEALINGS IN THE SOFTWARE.
"""

from .account_info import AccountInfo
from .author import Author
from .auto_completion_data import AutoCompletionData
from .background import Background
from .badge import Badge
from .coinshop_product import CoinshopProduct
from .organization import Organization
from .problem_level import ProblemLevel
from .problem_level_data import ProblemLevelData
from .problem_search_data import ProblemSearchData
from .problem_stats import ProblemStats
from .solvedac_statistics import SolvedAcStatistics
from .sort_direction import SortDirection
from .sort_type import SortType
from .tagged_problem import TaggedProblem
from .user import User
from .account_info import AccountInfo
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,14 @@
OTHER DEALINGS IN THE SOFTWARE.
"""

from datetime import datetime
from dataclasses import dataclass
from .auto_completion_data import SimplifiedUser
from .settings import Settings
from ..utils import get_datetime_from_string

from datetime import datetime
from typing import Dict, Union, List


@dataclass
class EmoticonInfo:
emoticon_id: str
emoticon_url: str
display_name: str
unlocked: bool

def __init__(self, data: Dict[str, Union[str, bool]]):
self.emoticon_id = data["emoticonId"]
self.emoticon_url = data["emoticonUrl"]
self.display_name = data["displayName"]
self.unlocked = data["unlocked"]
from solvedac_community.Schemas.Models.auto_completion_data import SimplifiedUser
from solvedac_community.Schemas.Models.emoticon_info import EmoticonInfo
from solvedac_community.Schemas.Models.settings import Settings
from solvedac_community.utils import get_datetime_from_string


@dataclass
Expand Down
27 changes: 27 additions & 0 deletions solvedac_community/Schemas/Models/auto_complete_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-

"""
Copyright (c) 2023 DevRuby
MIT License
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""

from dataclasses import dataclass
from typing import Dict


@dataclass()
class AutoCompleteText:
caption: str
description: str

def __init__(self, data: Dict[str, str]):
self.caption: str = data["caption"]
self.description: str = data["description"]
42 changes: 42 additions & 0 deletions solvedac_community/Schemas/Models/auto_completion_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-

"""
Copyright (c) 2023 DevRuby
MIT License
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""

from dataclasses import dataclass
from typing import Dict, Union, List

from solvedac_community.Schemas.Models.auto_complete_text import AutoCompleteText
from solvedac_community.Schemas.Models.simplified_problem import SimplifiedProblem
from solvedac_community.Schemas.Models.simplified_tag import SimplifiedTag
from solvedac_community.Schemas.Models.simplified_user import SimplifiedUser


@dataclass
class AutoCompletionData:
autocomplete: List[AutoCompleteText]
problems: List[SimplifiedProblem]
problem_count: int
tags: List[SimplifiedTag]
tag_count: int
users: List[SimplifiedUser]
user_count: int

def __init__(self, data: Dict[str, Union[list, int]]):
self.autocomplete: List[AutoCompleteText] = [AutoCompleteText(dat) for dat in data["autocomplete"]]
self.problems: List[SimplifiedProblem] = [SimplifiedProblem(dat) for dat in data["problems"]]
self.problem_count: int = data["problemCount"]
self.tags: List[SimplifiedTag] = [SimplifiedTag(dat) for dat in data["tags"]]
self.tag_count: int = data["tagCount"]
self.users: List[SimplifiedUser] = [SimplifiedUser(dat) for dat in data["users"]]
self.user_count: int = data["userCount"]
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"""

from dataclasses import dataclass
from typing import Dict, Union, Optional, List
from typing import Dict, Union, List

from .author import Author
from solvedac_community.Schemas.Models.author import Author


@dataclass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from dataclasses import dataclass
from typing import Dict

from .badge_tier import BadgeTier
from .badge_category import BadgeCategory
from solvedac_community.Schemas.Enums.badge_category import BadgeCategory
from solvedac_community.Schemas.Enums.badge_tier import BadgeTier


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"""

from dataclasses import dataclass
from typing import Dict, Optional, Union
from typing import Dict, Union

from .item import Item
from .price_unit import PriceUnit
from solvedac_community.Schemas.Enums.price_unit import PriceUnit
from solvedac_community.Schemas.Models.item import Item


@dataclass()
Expand Down
31 changes: 31 additions & 0 deletions solvedac_community/Schemas/Models/emoticon_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-

"""
Copyright (c) 2023 DevRuby
MIT License
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""

from dataclasses import dataclass
from typing import Dict, Union


@dataclass
class EmoticonInfo:
emoticon_id: str
emoticon_url: str
display_name: str
unlocked: bool

def __init__(self, data: Dict[str, Union[str, bool]]):
self.emoticon_id = data["emoticonId"]
self.emoticon_url = data["emoticonUrl"]
self.display_name = data["displayName"]
self.unlocked = data["unlocked"]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""

from dataclasses import dataclass
from typing import Dict, Union, List
from typing import Dict, Union


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dataclasses import dataclass
from typing import Dict, Union

from .problem_level import ProblemLevel
from solvedac_community.Schemas.Enums.problem_level import ProblemLevel


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

from dataclasses import dataclass
from typing import Dict
from .problem_level import ProblemLevel

from solvedac_community.Schemas.Enums.problem_level import ProblemLevel


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"""

from dataclasses import dataclass
from typing import Dict, Union
from typing import Dict

from .problem_level import ProblemLevel
from solvedac_community.Schemas.Enums.problem_level import ProblemLevel


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""

from dataclasses import dataclass
from typing import Dict, Union


@dataclass
Expand All @@ -41,4 +40,3 @@ def __init__(self, data: dict[str, str]):
self.twitter_post_on_problem_solve = data.get("twitter_post_on_problem_solve", "false") == "true"
self.twitter_post_on_rating_increase = data.get("twitter_post_on_rating_increase", "false") == "true"
self.twitter_post_on_tier_increase = data.get("twitter_post_on_tier_increase", "false") == "true"

37 changes: 37 additions & 0 deletions solvedac_community/Schemas/Models/simplified_problem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-

"""
Copyright (c) 2023 DevRuby
MIT License
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""

from dataclasses import dataclass
from typing import Dict, Union


@dataclass
class SimplifiedProblem:
id: int
title: str
level: int
solved: int
caption: str
description: str
href: str

def __init__(self, data: Dict[str, Union[int, str]]):
self.id: int = data["id"]
self.title: str = data["title"]
self.level: int = data["level"]
self.solved: int = data["solved"]
self.caption: str = data["caption"]
self.description: str = data["description"]
self.href: str = data["href"]
Loading