Habiticalib 0.3.5__py3-none-any.whl → 0.3.7rc0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- habiticalib/__init__.py +215 -4
- habiticalib/const.py +1 -1
- habiticalib/exceptions.py +1 -1
- habiticalib/helpers.py +5 -5
- habiticalib/lib.py +20 -18
- habiticalib/{types.py → typedefs.py} +279 -247
- {habiticalib-0.3.5.dist-info → habiticalib-0.3.7rc0.dist-info}/METADATA +1 -1
- habiticalib-0.3.7rc0.dist-info/RECORD +12 -0
- habiticalib-0.3.5.dist-info/RECORD +0 -12
- {habiticalib-0.3.5.dist-info → habiticalib-0.3.7rc0.dist-info}/WHEEL +0 -0
- {habiticalib-0.3.5.dist-info → habiticalib-0.3.7rc0.dist-info}/licenses/LICENSE +0 -0
habiticalib/__init__.py
CHANGED
@@ -8,14 +8,45 @@ from .exceptions import (
|
|
8
8
|
NotFoundError,
|
9
9
|
TooManyRequestsError,
|
10
10
|
)
|
11
|
-
from .helpers import deserialize_task
|
11
|
+
from .helpers import deserialize_task, extract_avatar
|
12
12
|
from .lib import Habitica
|
13
|
-
from .
|
13
|
+
from .typedefs import (
|
14
|
+
AchievementsUser,
|
15
|
+
AchievmentContent,
|
16
|
+
ActiveFilterTask,
|
17
|
+
AnimalColorAchievementContent,
|
18
|
+
AnimalSetAchievementContent,
|
14
19
|
Attributes,
|
20
|
+
AuthUser,
|
21
|
+
Avatar,
|
22
|
+
BackerUser,
|
23
|
+
BuffsStats,
|
24
|
+
BuffsStatsavatar,
|
25
|
+
CardTypes,
|
26
|
+
Challenge,
|
27
|
+
ChallengeAbortedReason,
|
15
28
|
ChangeClassData,
|
29
|
+
Checklist,
|
30
|
+
CommonTutorial,
|
31
|
+
CompletedBy,
|
32
|
+
ConsecutivePlan,
|
16
33
|
ContentData,
|
34
|
+
ContributorUser,
|
17
35
|
Direction,
|
36
|
+
DropTmpScore,
|
37
|
+
EggEntry,
|
38
|
+
EmailNotificationsPreferences,
|
39
|
+
EntryHistory,
|
40
|
+
EquippedGear,
|
41
|
+
FlagsUser,
|
18
42
|
Frequency,
|
43
|
+
GearClass,
|
44
|
+
GearContent,
|
45
|
+
GearEntry,
|
46
|
+
GearItems,
|
47
|
+
GearItemsAvatar,
|
48
|
+
GearType,
|
49
|
+
GroupTask,
|
19
50
|
HabiticaCastSkillResponse,
|
20
51
|
HabiticaClass,
|
21
52
|
HabiticaClassSystemResponse,
|
@@ -36,74 +67,254 @@ from .types import (
|
|
36
67
|
HabiticaUserAnonymizedResponse,
|
37
68
|
HabiticaUserExport,
|
38
69
|
HabiticaUserResponse,
|
70
|
+
HairPreferences,
|
71
|
+
HatchingPotionEntry,
|
72
|
+
HistoryUser,
|
73
|
+
InboxUser,
|
74
|
+
InventoryItemEntry,
|
75
|
+
InvitationsUser,
|
76
|
+
IosTutorial,
|
77
|
+
ItemListContent,
|
78
|
+
ItemListEntry,
|
79
|
+
ItemsAvatar,
|
80
|
+
ItemsUser,
|
39
81
|
Language,
|
82
|
+
LastDropItems,
|
83
|
+
LocalAuth,
|
84
|
+
LocalTimestamps,
|
40
85
|
LoginData,
|
86
|
+
NotificationsUser,
|
87
|
+
PartyMember,
|
88
|
+
PartyUser,
|
89
|
+
PermissionsUser,
|
90
|
+
PetEntry,
|
91
|
+
PetSetCompleteAchievsContent,
|
92
|
+
PinnedItemsUser,
|
93
|
+
PlanPurchased,
|
94
|
+
PreferencesAvatar,
|
95
|
+
PreferencesUser,
|
96
|
+
ProfileUser,
|
97
|
+
ProgressQuest,
|
98
|
+
PurchasedUser,
|
99
|
+
PushDevicesUser,
|
100
|
+
PushNotificationsPreferences,
|
101
|
+
QuestBoss,
|
102
|
+
QuestBossRage,
|
103
|
+
QuestCollect,
|
41
104
|
QuestData,
|
105
|
+
QuestDrop,
|
106
|
+
QuestItem,
|
107
|
+
QuestParty,
|
108
|
+
QuestsAchievments,
|
109
|
+
QuestsContent,
|
110
|
+
QuestTmpScore,
|
111
|
+
QuestUnlockCondition,
|
112
|
+
Reminders,
|
42
113
|
Repeat,
|
43
114
|
ScoreData,
|
44
115
|
Skill,
|
116
|
+
SpecialItemEntry,
|
117
|
+
SpecialItems,
|
118
|
+
SpellEntry,
|
119
|
+
SpellsClass,
|
120
|
+
StableAchievementContent,
|
121
|
+
StatsAvatar,
|
45
122
|
StatsUser,
|
123
|
+
SuppressModalsPreferences,
|
46
124
|
TagsUser,
|
47
125
|
Task,
|
48
126
|
TaskData,
|
49
127
|
TaskFilter,
|
50
128
|
TaskPriority,
|
129
|
+
TasksOrderUser,
|
130
|
+
TasksPreferences,
|
131
|
+
TasksUserExport,
|
51
132
|
TaskType,
|
133
|
+
TmpScore,
|
134
|
+
TourFlags,
|
135
|
+
TrainingStats,
|
136
|
+
TutorialFlags,
|
137
|
+
UltimateGearSetsAchievments,
|
52
138
|
UserAnonymizedData,
|
53
139
|
UserData,
|
54
|
-
|
140
|
+
UserTasks,
|
141
|
+
WebhooksOptions,
|
142
|
+
WebhooksType,
|
143
|
+
WebhooksUser,
|
55
144
|
)
|
56
145
|
|
57
146
|
__all__ = [
|
58
147
|
"ASSETS_URL",
|
59
148
|
"DEFAULT_URL",
|
149
|
+
"AchievementsUser",
|
150
|
+
"AchievmentContent",
|
151
|
+
"ActiveFilterTask",
|
152
|
+
"AnimalColorAchievementContent",
|
153
|
+
"AnimalSetAchievementContent",
|
60
154
|
"Attributes",
|
155
|
+
"AuthUser",
|
156
|
+
"Avatar",
|
157
|
+
"BackerUser",
|
61
158
|
"BadRequestError",
|
159
|
+
"BuffsStats",
|
160
|
+
"BuffsStatsavatar",
|
161
|
+
"CardTypes",
|
162
|
+
"Challenge",
|
163
|
+
"ChallengeAbortedReason",
|
62
164
|
"ChangeClassData",
|
165
|
+
"ChangeClassData",
|
166
|
+
"Checklist",
|
167
|
+
"Checklist",
|
168
|
+
"CommonTutorial",
|
169
|
+
"CompletedBy",
|
170
|
+
"ConsecutivePlan",
|
171
|
+
"ContentData",
|
63
172
|
"ContentData",
|
173
|
+
"ContributorUser",
|
64
174
|
"Direction",
|
175
|
+
"DropTmpScore",
|
176
|
+
"EggEntry",
|
177
|
+
"EmailNotificationsPreferences",
|
178
|
+
"EntryHistory",
|
179
|
+
"EquippedGear",
|
180
|
+
"FlagsUser",
|
65
181
|
"Frequency",
|
182
|
+
"GearClass",
|
183
|
+
"GearContent",
|
184
|
+
"GearEntry",
|
185
|
+
"GearItems",
|
186
|
+
"GearItemsAvatar",
|
187
|
+
"GearType",
|
188
|
+
"GroupTask",
|
66
189
|
"Habitica",
|
67
190
|
"HabiticaCastSkillResponse",
|
191
|
+
"HabiticaCastSkillResponse",
|
68
192
|
"HabiticaClass",
|
69
193
|
"HabiticaClassSystemResponse",
|
194
|
+
"HabiticaClassSystemResponse",
|
70
195
|
"HabiticaContentResponse",
|
196
|
+
"HabiticaContentResponse",
|
197
|
+
"HabiticaErrorResponse",
|
71
198
|
"HabiticaErrorResponse",
|
72
199
|
"HabiticaException",
|
73
200
|
"HabiticaGroupMembersResponse",
|
201
|
+
"HabiticaGroupMembersResponse",
|
202
|
+
"HabiticaLoginResponse",
|
74
203
|
"HabiticaLoginResponse",
|
75
204
|
"HabiticaQuestResponse",
|
205
|
+
"HabiticaQuestResponse",
|
206
|
+
"HabiticaResponse",
|
76
207
|
"HabiticaResponse",
|
77
208
|
"HabiticaScoreResponse",
|
209
|
+
"HabiticaScoreResponse",
|
210
|
+
"HabiticaSleepResponse",
|
78
211
|
"HabiticaSleepResponse",
|
79
212
|
"HabiticaStatsResponse",
|
213
|
+
"HabiticaStatsResponse",
|
214
|
+
"HabiticaTagResponse",
|
80
215
|
"HabiticaTagResponse",
|
81
216
|
"HabiticaTagsResponse",
|
217
|
+
"HabiticaTagsResponse",
|
82
218
|
"HabiticaTaskOrderResponse",
|
219
|
+
"HabiticaTaskOrderResponse",
|
220
|
+
"HabiticaTaskResponse",
|
83
221
|
"HabiticaTaskResponse",
|
84
222
|
"HabiticaTasksResponse",
|
223
|
+
"HabiticaTasksResponse",
|
224
|
+
"HabiticaUserAnonymizedResponse",
|
85
225
|
"HabiticaUserAnonymizedResponse",
|
86
226
|
"HabiticaUserExport",
|
227
|
+
"HabiticaUserExport",
|
228
|
+
"HabiticaUserResponse",
|
87
229
|
"HabiticaUserResponse",
|
230
|
+
"HairPreferences",
|
231
|
+
"HatchingPotionEntry",
|
232
|
+
"HistoryUser",
|
233
|
+
"InboxUser",
|
234
|
+
"InventoryItemEntry",
|
235
|
+
"InvitationsUser",
|
236
|
+
"IosTutorial",
|
237
|
+
"ItemListContent",
|
238
|
+
"ItemListEntry",
|
239
|
+
"ItemsAvatar",
|
240
|
+
"ItemsUser",
|
88
241
|
"Language",
|
242
|
+
"LastDropItems",
|
243
|
+
"LocalAuth",
|
244
|
+
"LocalTimestamps",
|
245
|
+
"LoginData",
|
89
246
|
"LoginData",
|
90
247
|
"NotAuthorizedError",
|
91
248
|
"NotFoundError",
|
249
|
+
"NotificationsUser",
|
250
|
+
"PartyMember",
|
251
|
+
"PartyUser",
|
252
|
+
"PermissionsUser",
|
253
|
+
"PetEntry",
|
254
|
+
"PetSetCompleteAchievsContent",
|
255
|
+
"PinnedItemsUser",
|
256
|
+
"PlanPurchased",
|
257
|
+
"PreferencesAvatar",
|
258
|
+
"PreferencesUser",
|
259
|
+
"ProfileUser",
|
260
|
+
"ProgressQuest",
|
261
|
+
"PurchasedUser",
|
262
|
+
"PushDevicesUser",
|
263
|
+
"PushNotificationsPreferences",
|
264
|
+
"QuestBoss",
|
265
|
+
"QuestBossRage",
|
266
|
+
"QuestCollect",
|
267
|
+
"QuestData",
|
92
268
|
"QuestData",
|
269
|
+
"QuestDrop",
|
270
|
+
"QuestItem",
|
271
|
+
"QuestParty",
|
272
|
+
"QuestTmpScore",
|
273
|
+
"QuestUnlockCondition",
|
274
|
+
"QuestsAchievments",
|
275
|
+
"QuestsContent",
|
276
|
+
"Reminders",
|
93
277
|
"Repeat",
|
278
|
+
"Repeat",
|
279
|
+
"ScoreData",
|
94
280
|
"ScoreData",
|
95
281
|
"Skill",
|
282
|
+
"SpecialItemEntry",
|
283
|
+
"SpecialItems",
|
284
|
+
"SpellEntry",
|
285
|
+
"SpellsClass",
|
286
|
+
"StableAchievementContent",
|
287
|
+
"StatsAvatar",
|
96
288
|
"StatsUser",
|
289
|
+
"StatsUser",
|
290
|
+
"SuppressModalsPreferences",
|
291
|
+
"TagsUser",
|
97
292
|
"TagsUser",
|
98
293
|
"Task",
|
99
294
|
"TaskData",
|
295
|
+
"TaskData",
|
100
296
|
"TaskFilter",
|
101
297
|
"TaskPriority",
|
102
298
|
"TaskType",
|
299
|
+
"TasksOrderUser",
|
300
|
+
"TasksPreferences",
|
301
|
+
"TasksUserExport",
|
302
|
+
"TmpScore",
|
103
303
|
"TooManyRequestsError",
|
304
|
+
"TourFlags",
|
305
|
+
"TrainingStats",
|
306
|
+
"TutorialFlags",
|
307
|
+
"UltimateGearSetsAchievments",
|
308
|
+
"UserAnonymizedData",
|
104
309
|
"UserAnonymizedData",
|
105
310
|
"UserData",
|
106
|
-
"
|
311
|
+
"UserData",
|
312
|
+
"UserTasks",
|
313
|
+
"UserTasks",
|
314
|
+
"WebhooksOptions",
|
315
|
+
"WebhooksType",
|
316
|
+
"WebhooksUser",
|
107
317
|
"__version__",
|
108
318
|
"deserialize_task",
|
319
|
+
"extract_avatar",
|
109
320
|
]
|
habiticalib/const.py
CHANGED
habiticalib/exceptions.py
CHANGED
habiticalib/helpers.py
CHANGED
@@ -10,7 +10,7 @@ import uuid
|
|
10
10
|
import aiohttp
|
11
11
|
|
12
12
|
from .const import DEVELOPER_ID, __version__
|
13
|
-
from .
|
13
|
+
from .typedefs import Avatar, UserData
|
14
14
|
|
15
15
|
|
16
16
|
def join_fields(user_fields: list[str] | str) -> str:
|
@@ -111,10 +111,10 @@ def get_x_client(x_client: str | None = None) -> str:
|
|
111
111
|
return f"{DEVELOPER_ID} - Habiticalib/{__version__}"
|
112
112
|
|
113
113
|
|
114
|
-
def
|
115
|
-
"""Extract
|
116
|
-
|
117
|
-
return
|
114
|
+
def extract_avatar(user_data: UserData) -> Avatar:
|
115
|
+
"""Extract avatar defs from a user data object."""
|
116
|
+
|
117
|
+
return Avatar.from_dict(user_data.to_dict())
|
118
118
|
|
119
119
|
|
120
120
|
def deserialize_task(value: Any) -> Any: # noqa: PLR0911
|
habiticalib/lib.py
CHANGED
@@ -29,13 +29,14 @@ from .exceptions import (
|
|
29
29
|
)
|
30
30
|
from .helpers import (
|
31
31
|
deserialize_task,
|
32
|
-
|
32
|
+
extract_avatar,
|
33
33
|
get_user_agent,
|
34
34
|
get_x_client,
|
35
35
|
join_fields,
|
36
36
|
)
|
37
|
-
from .
|
37
|
+
from .typedefs import (
|
38
38
|
Attributes,
|
39
|
+
Avatar,
|
39
40
|
Direction,
|
40
41
|
HabiticaCastSkillResponse,
|
41
42
|
HabiticaClass,
|
@@ -61,7 +62,6 @@ from .types import (
|
|
61
62
|
Skill,
|
62
63
|
Task,
|
63
64
|
TaskFilter,
|
64
|
-
UserStyles,
|
65
65
|
)
|
66
66
|
|
67
67
|
if TYPE_CHECKING:
|
@@ -1845,12 +1845,12 @@ class Habitica:
|
|
1845
1845
|
async def generate_avatar( # noqa: PLR0912, PLR0915
|
1846
1846
|
self,
|
1847
1847
|
fp: str | IO[bytes],
|
1848
|
-
|
1848
|
+
avatar: Avatar | None = None,
|
1849
1849
|
fmt: str | None = None,
|
1850
|
-
) ->
|
1851
|
-
"""Generate an avatar image based on the provided
|
1850
|
+
) -> Avatar:
|
1851
|
+
"""Generate an avatar image based on the provided avatar object or fetched user data.
|
1852
1852
|
|
1853
|
-
If no `
|
1853
|
+
If no `Avatar` object is provided, the method retrieves user preferences, items, and stats
|
1854
1854
|
for the authenticated user and builds the avatar accordingly. The base image is initialized
|
1855
1855
|
as a transparent RGBA image of size (141, 147). A mount offset is applied based on the user's
|
1856
1856
|
current mount status.
|
@@ -1864,8 +1864,8 @@ class Habitica:
|
|
1864
1864
|
----------
|
1865
1865
|
fp : str or IO[bytes]
|
1866
1866
|
The file path or a bytes buffer to store or modify the avatar image.
|
1867
|
-
|
1868
|
-
The user
|
1867
|
+
avatar : Avatar, optional
|
1868
|
+
The user avatar preferences, items, and stats. If not provided, the method will fetch
|
1869
1869
|
this data.
|
1870
1870
|
fmt : str
|
1871
1871
|
If a file object is used instead of a filename, the format
|
@@ -1873,8 +1873,8 @@ class Habitica:
|
|
1873
1873
|
|
1874
1874
|
Returns
|
1875
1875
|
-------
|
1876
|
-
|
1877
|
-
The user
|
1876
|
+
Avatar
|
1877
|
+
The user avatar definitions used to generate the avatar.
|
1878
1878
|
|
1879
1879
|
Examples
|
1880
1880
|
--------
|
@@ -1885,13 +1885,15 @@ class Habitica:
|
|
1885
1885
|
Using a file path:
|
1886
1886
|
>>> await habitica.generate_avatar("/path/to/image/avatar.png")
|
1887
1887
|
"""
|
1888
|
-
if not
|
1889
|
-
|
1890
|
-
|
1888
|
+
if not avatar:
|
1889
|
+
avatar = extract_avatar(
|
1890
|
+
(
|
1891
|
+
await self.get_user(user_fields=["preferences", "items", "stats"])
|
1892
|
+
).data,
|
1891
1893
|
)
|
1892
|
-
preferences =
|
1893
|
-
items =
|
1894
|
-
stats =
|
1894
|
+
preferences = avatar.preferences
|
1895
|
+
items = avatar.items
|
1896
|
+
stats = avatar.stats
|
1895
1897
|
mount_offset_y = 0 if items.currentMount else 24
|
1896
1898
|
|
1897
1899
|
# Initializing the base image
|
@@ -2040,7 +2042,7 @@ class Habitica:
|
|
2040
2042
|
else:
|
2041
2043
|
image.save(fp, fmt)
|
2042
2044
|
|
2043
|
-
return
|
2045
|
+
return avatar
|
2044
2046
|
|
2045
2047
|
async def habitipy(self) -> HabitipyAsync:
|
2046
2048
|
"""Create a Habitipy instance."""
|