Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 8968549

Browse files
authored
Merge pull request #19 from ClementJ18/develop
v0.4.3 release
2 parents b79abe6 + 7bd9915 commit 8968549

File tree

8 files changed

+83
-20
lines changed

8 files changed

+83
-20
lines changed

docs/source/changelog.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ The page attempt to keep a clear list of breaking/non-breaking changes and new f
88
:local:
99
:backlinks: none
1010

11+
v0.4.3
12+
-------
13+
14+
New Features
15+
#############
16+
* `Platform` object has been split into `GamePlatform`, `ModPlatform` and `ModFilePlatform` to better reflect the API models
17+
* New `Mod.platforms` attribute
18+
* `Game.platforms`is now a `List[GamePlatform]`, different class but same attributes
19+
20+
Bugs Fixed
21+
###########
22+
* `Modfile.platforms` fixed, now a `List[ModFilePlatforms]` with correct attributes
23+
1124
v0.4.2
1225
-------
1326

@@ -76,4 +89,3 @@ Removed Features
7689
* Many of exceptions have been removed, the library now uses the base exception for most errors
7790
* Removed the account links support, looking into a better implementation
7891
* Many removed endpoints have had their method also removed
79-
*

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# The short X.Y version
2828
version = ""
2929
# The full version, including alpha/beta/rc tags
30-
release = "0.4.2"
30+
release = "0.4.3"
3131

3232

3333
# -- General configuration ---------------------------------------------------

modio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
from .enums import *
88
from .errors import *
99

10-
__version__ = "0.4.2"
10+
__version__ = "0.4.3"

modio/client.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def async_enforce_ratelimit(self):
7474

7575
def _error_check(self, resp, request_json):
7676
"""Updates the rate-limit attributes and check validity of the request."""
77-
self.retry_after = resp.headers.get("retry-after", 0)
77+
self.retry_after = int(resp.headers.get("retry-after", "0"))
7878
code = getattr(resp, "status_code", getattr(resp, "status", None))
7979

8080
if code == 204:
@@ -124,12 +124,12 @@ def _post(self, resp):
124124
except requests.JSONDecodeError:
125125
resp_json = {}
126126

127-
try:
127+
try:
128128
data = self._error_check(resp, resp_json)
129129
except modioException as e:
130130
if e.code == 429:
131131
self.enforce_ratelimit()
132-
132+
133133
raise e
134134

135135
return data
@@ -165,13 +165,12 @@ async def _async_post(self, resp):
165165
except aiohttp.ContentTypeError:
166166
resp_json = {}
167167

168-
169-
try:
168+
try:
170169
data = self._error_check(resp, resp_json)
171170
except modioException as e:
172171
if e.code == 429:
173172
await self.async_enforce_ratelimit()
174-
173+
175174
raise e
176175

177176
return data

modio/entities.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .mixins import OwnerMixin, RatingMixin, ReportMixin, StatsMixin
55
from .errors import modioException
66
from .utils import concat_docs, _convert_date
7-
from .enums import EventType, RatingType, TargetPlatform, VirusStatus
7+
from .enums import EventType, RatingType, TargetPlatform, VirusStatus, ModFilePlatformStatus
88

99

1010
class Message:
@@ -299,7 +299,7 @@ class ModFile(OwnerMixin):
299299
game_id : int
300300
ID of the game of the mod this file belongs to. Can be None if this file
301301
was returned from the me/modfiles endpoint.
302-
platforms : List[Platform]
302+
platforms : List[ModFilePlatform]
303303
List of platforms this file is avalaible on.
304304
"""
305305

@@ -323,7 +323,7 @@ def __init__(self, **attrs):
323323
self.url = download["binary_url"]
324324
self.date_expires = _convert_date(download.pop("date_expires"))
325325
self.game_id = attrs.pop("game_id", None)
326-
self.platforms = [Platform(**platform) for platform in attrs.pop("platforms")]
326+
self.platforms = [ModFilePlatform(**platform) for platform in attrs.pop("platforms")]
327327
self.connection = attrs.pop("connection")
328328

329329
def __repr__(self):
@@ -436,8 +436,15 @@ def __init__(self, **attrs):
436436
self.images = [Image(**image) for image in attrs.pop("images", [])]
437437

438438

439-
class Platform:
440-
"""A platform
439+
class BasePlatform:
440+
"""Base class for a platform."""
441+
442+
def __init__(self, **attrs):
443+
self.platform = TargetPlatform[attrs.pop("platform")]
444+
445+
446+
class GamePlatform(BasePlatform):
447+
"""The platform for a game.
441448
442449
Attributes
443450
----------
@@ -450,11 +457,43 @@ class Platform:
450457
"""
451458

452459
def __init__(self, **attrs):
453-
self.platform = TargetPlatform[attrs.pop("platform")]
460+
super().__init__(**attrs)
454461
self.label = attrs.pop("label")
455462
self.moderated = attrs.pop("moderated")
456463

457464

465+
class ModPlatform(BasePlatform):
466+
"""The platform for a mod
467+
468+
Attributes
469+
------------
470+
platform : TargetPlatform
471+
The platform
472+
modfile_live : int
473+
The ID of the modfile currently live for that platform.
474+
"""
475+
476+
def __init__(self, **attrs):
477+
super().__init__(**attrs)
478+
self.modfile_live = attrs.pop("modfile_live")
479+
480+
481+
class ModFilePlatform:
482+
"""The platform for a mod file
483+
484+
Attributes
485+
-----------
486+
platform : TargetPlatform
487+
The platform
488+
status : ModFilePlatformStatus
489+
The status of the modfile for the corresponding platform.
490+
"""
491+
492+
def __init__(self, **attrs):
493+
super().__init__(**attrs)
494+
self.status = ModFilePlatformStatus(attrs.pop("status"))
495+
496+
458497
class TagOption:
459498
"""Represents a game tag gropup, a category of tags from which a
460499
mod may pick one or more.

modio/enums.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ class Status(enum.Enum):
4545
deleted = 3
4646

4747

48+
class ModFilePlatformStatus:
49+
"""Status of a modfile for the specific platform.
50+
51+
0 : Pending
52+
1 : Accepted
53+
2 : Denied
54+
"""
55+
56+
pending = 0
57+
accepted = 1
58+
denied = 2
59+
60+
4861
class Presentation(enum.Enum):
4962
"""
5063
0 : Display mods for that game in a grid on mod.io

modio/game.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import List, Literal, Optional
44

55
from .mod import Mod
6-
from .entities import Event, Image, Message, GameStats, ModStats, Platform, TagOption, User
6+
from .entities import Event, Image, Message, GameStats, ModStats, GamePlatform, TagOption, User
77
from .objects import Filter, NewMod, Pagination, Returned
88
from .utils import _convert_date, find
99
from .enums import APIAccess, Community, Curation, MaturityOptions, Presentation, Revenue, Status, Submission
@@ -73,7 +73,7 @@ class Game(ReportMixin, OwnerMixin):
7373
other_urls : Dict[str, str]
7474
A dictionnary of labels and urls for
7575
the game
76-
platforms : List[Platform]
76+
platforms : List[GamePlatform]
7777
Platforms this games supports
7878
"""
7979

@@ -113,7 +113,7 @@ def __init__(self, **attrs):
113113
self.stats = None
114114
# self.theme = Theme(**attrs.pop("theme"))
115115
self.other_urls = {value["label"]: value["url"] for value in attrs.pop("other_urls")}
116-
self.platforms = [Platform(**platform) for platform in attrs.pop("platforms")]
116+
self.platforms = [GamePlatform(**platform) for platform in attrs.pop("platforms")]
117117

118118
_submitter = attrs.pop("submitted_by", {})
119119
if _submitter:

modio/mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async def async_delete(self):
111111
class OwnerMixin:
112112
"""Mixin containing get owner methods."""
113113

114-
def get_owner(self) -> 'entities.User':
114+
def get_owner(self) -> "entities.User":
115115
"""Get the original submitter of the resource.
116116
117117
|coro|
@@ -126,7 +126,7 @@ def get_owner(self) -> 'entities.User':
126126
)
127127
return entities.User(connection=self.connection, **user)
128128

129-
async def async_get_owner(self) -> 'entities.User':
129+
async def async_get_owner(self) -> "entities.User":
130130
user = await self.connection.async_post_request(
131131
"/general/ownership", data={"resource_type": self._resource_type, "resource_id": self.id}
132132
)

0 commit comments

Comments
 (0)