Skip to content

Commit

Permalink
fix: bungie has very inconsistent naming schemes. Fun :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kigstn committed Feb 22, 2023
1 parent 5c04280 commit 8a518f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions bungio/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,17 @@ async def from_dict(cls, data: dict, client: "Client", recursive: bool = False,
prepared = {}
for name, field in attrs.fields_dict(cls).items():
if field.init and name != "_client":
# get the value we want. This also skips the manifest_... entries since they have no value and a default
value = data.get(cls._convert_to_bungie_case(name), attrs.NOTHING)
default = field.default

# get the value we want. This also skips the manifest_... entries since they have no value and a default
bungie_name = cls._convert_to_bungie_case(name)
value = data.get(bungie_name, attrs.NOTHING)

# bungie is veeery inconsistent and sometimes like to start their params with an upper case for some reason
# only sometimes tho :)
if value is attrs.NOTHING:
value = data.get(f"{bungie_name[0].capitalize()}{bungie_name[1:]}", attrs.NOTHING)

# sadly bungie sometimes does not return info without marking that fact in the api specs
if value is attrs.NOTHING and default is attrs.NOTHING:
default = MISSING
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bungio"
version = "0.7.2"
version = "0.7.3"
description = "A destiny 2 / bungie api wrapper"
keywords = ["asyncio", "destiny", "destiny 2", "bungie", "api"]
readme = "README.md"
Expand Down

0 comments on commit 8a518f7

Please sign in to comment.