pychpp 0.4.0b2__tar.gz → 0.4.1__tar.gz

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.
Files changed (67) hide show
  1. {pychpp-0.4.0b2 → pychpp-0.4.1}/PKG-INFO +5 -2
  2. {pychpp-0.4.0b2 → pychpp-0.4.1}/README.md +3 -1
  3. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/chpp.py +84 -1
  4. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_team.py +2 -1
  5. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/ht_model.py +34 -11
  6. pychpp-0.4.1/pychpp/models/xml/alliance_details.py +137 -0
  7. pychpp-0.4.1/pychpp/models/xml/alliances.py +36 -0
  8. pychpp-0.4.1/pychpp/models/xml/avatars.py +56 -0
  9. {pychpp-0.4.0b2 → pychpp-0.4.1}/pyproject.toml +2 -2
  10. {pychpp-0.4.0b2 → pychpp-0.4.1}/LICENSE +0 -0
  11. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/__init__.py +0 -0
  12. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/fixtures/__init__.py +0 -0
  13. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/fixtures/ht_datetime.py +0 -0
  14. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/fixtures/ht_error.py +0 -0
  15. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/__init__.py +0 -0
  16. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/__init__.py +0 -0
  17. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/__init__.py +0 -0
  18. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_arena.py +0 -0
  19. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_country.py +0 -0
  20. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_league.py +0 -0
  21. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_league_unit.py +0 -0
  22. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_match.py +0 -0
  23. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_player.py +0 -0
  24. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_region.py +0 -0
  25. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_team.py +0 -0
  26. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/base/ht_user.py +0 -0
  27. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_arena.py +0 -0
  28. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_challenge.py +0 -0
  29. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_league.py +0 -0
  30. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_league_unit.py +0 -0
  31. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_match.py +0 -0
  32. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_match_lineup.py +0 -0
  33. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_matches_archive.py +0 -0
  34. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_player.py +0 -0
  35. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_region.py +0 -0
  36. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_transfer_history.py +0 -0
  37. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_user.py +0 -0
  38. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_youth_player.py +0 -0
  39. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/custom/ht_youth_team.py +0 -0
  40. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/ht_field.py +0 -0
  41. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/ht_init_var.py +0 -0
  42. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/ht_version.py +0 -0
  43. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/ht_xml.py +0 -0
  44. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/__init__.py +0 -0
  45. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/achievements.py +0 -0
  46. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/arena_details.py +0 -0
  47. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/challenges.py +0 -0
  48. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/cup_matches.py +0 -0
  49. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/league_details.py +0 -0
  50. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/league_fixtures.py +0 -0
  51. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/manager_compendium.py +0 -0
  52. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/match_details.py +0 -0
  53. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/match_lineup.py +0 -0
  54. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/matches_archive.py +0 -0
  55. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/national_team_details.py +0 -0
  56. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/national_teams.py +0 -0
  57. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/player_details.py +0 -0
  58. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/players.py +0 -0
  59. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/region_details.py +0 -0
  60. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/team_details.py +0 -0
  61. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/training.py +0 -0
  62. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/transfers_team.py +0 -0
  63. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/world_cup.py +0 -0
  64. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/world_details.py +0 -0
  65. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/youth_player_details.py +0 -0
  66. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/youth_player_list.py +0 -0
  67. {pychpp-0.4.0b2 → pychpp-0.4.1}/pychpp/models/xml/youth_team_details.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pychpp
3
- Version: 0.4.0b2
3
+ Version: 0.4.1
4
4
  Summary: framework created to use the API provided by the online game Hattrick
5
5
  Home-page: https://framagit.org/Pierre86/pychpp
6
6
  License: Apache-2.0
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
17
18
  Requires-Dist: Werkzeug (>=2.2.2,<3.0.0)
18
19
  Requires-Dist: pytz (>=2024.2,<2025.0)
19
20
  Requires-Dist: rauth (>=0.7.3,<0.8.0)
@@ -164,13 +165,15 @@ Then, to use this new class:
164
165
  In this way, only the data you're really interested in is parsed, which can in some cases be interesting from a performance point of view.
165
166
 
166
167
  ## List of supported CHPP XML files
167
- ![23/57](https://progress-bar.xyz/40/?title=23%20on%2057)
168
+ ![26/57](https://progress-bar.xyz/46/?title=26%20on%2057)
168
169
 
169
170
  The following table shows the CHPP XML files that are currently supported:
170
171
 
171
172
  | pyCHPP class | CHPP XML files |
172
173
  |:-------------------:|:-------------------------:|
173
174
  | Achievements | `achievements.xml` |
175
+ | Alliances | `alliances.xml` |
176
+ | AllianceDetails | `alliancedetails.xml` |
174
177
  | Arena | `arenadetails.xml` |
175
178
  | Challenges | `challenges.xml` |
176
179
  | CupMatches | `cupmatches.xml` |
@@ -143,13 +143,15 @@ Then, to use this new class:
143
143
  In this way, only the data you're really interested in is parsed, which can in some cases be interesting from a performance point of view.
144
144
 
145
145
  ## List of supported CHPP XML files
146
- ![23/57](https://progress-bar.xyz/40/?title=23%20on%2057)
146
+ ![26/57](https://progress-bar.xyz/46/?title=26%20on%2057)
147
147
 
148
148
  The following table shows the CHPP XML files that are currently supported:
149
149
 
150
150
  | pyCHPP class | CHPP XML files |
151
151
  |:-------------------:|:-------------------------:|
152
152
  | Achievements | `achievements.xml` |
153
+ | Alliances | `alliances.xml` |
154
+ | AllianceDetails | `alliancedetails.xml` |
153
155
  | Arena | `arenadetails.xml` |
154
156
  | Challenges | `challenges.xml` |
155
157
  | CupMatches | `cupmatches.xml` |
@@ -11,7 +11,8 @@ from pychpp.models.xml import (manager_compendium, team_details, achievements, a
11
11
  match_lineup, national_teams, national_team_details, player_details,
12
12
  training, transfers_team, world_details, world_cup, players,
13
13
  youth_player_details, youth_team_details, youth_player_list,
14
- matches_archive, match_details, cup_matches)
14
+ matches_archive, match_details, cup_matches, alliances,
15
+ alliance_details, avatars)
15
16
  from pychpp.models.custom import (ht_team, ht_arena, ht_user, ht_region, ht_youth_team, ht_player,
16
17
  ht_league_unit, ht_youth_player, ht_league, ht_matches_archive,
17
18
  ht_match, ht_challenge, ht_match_lineup, ht_transfer_history)
@@ -371,6 +372,74 @@ class CHPPXml(CHPPBase):
371
372
 
372
373
  return achievements.Achievements(chpp=self, user_id=user_id)
373
374
 
375
+ def xml_alliances(
376
+ self,
377
+ search_for: str,
378
+ search_type: int = None,
379
+ search_language_id: int = None,
380
+ page_index: int = None,
381
+ **kwargs,
382
+ ) -> alliances.Alliances:
383
+
384
+ return alliances.Alliances(
385
+ chpp=self,
386
+ search_type=search_type,
387
+ search_for=search_for,
388
+ search_language_id=search_language_id,
389
+ page_index=page_index,
390
+ **kwargs,
391
+ )
392
+
393
+ def xml_alliance_details(
394
+ self,
395
+ action_type: str = 'view',
396
+ subset: int = None,
397
+ alliance_id: int = None,
398
+ **kwargs,
399
+ ) -> Union[alliance_details.AllianceDetailsView,
400
+ alliance_details.AllianceDetailsRoles,
401
+ alliance_details.AllianceDetailsMembers,
402
+ alliance_details.AllianceDetailsMembersSubset,
403
+ ]:
404
+
405
+ if action_type == 'view':
406
+ return alliance_details.AllianceDetailsView(
407
+ chpp=self,
408
+ action_type=action_type,
409
+ alliance_id=alliance_id,
410
+ **kwargs,
411
+ )
412
+
413
+ elif action_type == 'roles':
414
+ return alliance_details.AllianceDetailsRoles(
415
+ chpp=self,
416
+ action_type=action_type,
417
+ alliance_id=alliance_id,
418
+ **kwargs,
419
+ )
420
+
421
+ elif action_type == 'members':
422
+ return alliance_details.AllianceDetailsMembers(
423
+ chpp=self,
424
+ action_type=action_type,
425
+ alliance_id=alliance_id,
426
+ **kwargs,
427
+ )
428
+
429
+ elif action_type == 'membersSubset':
430
+ return alliance_details.AllianceDetailsMembersSubset(
431
+ chpp=self,
432
+ action_type=action_type,
433
+ subset=subset,
434
+ alliance_id=alliance_id,
435
+ **kwargs,
436
+ )
437
+
438
+ else:
439
+ ValueError("'action_type' argument must be "
440
+ "equal to 'view', 'roles', "
441
+ "'members' or 'membersSubset'")
442
+
374
443
  def xml_arena_details(
375
444
  self, stats_type: str = None, arena_id: int = None, team_id: int = None,
376
445
  match_type: str = None, first_date: datetime = None,
@@ -399,6 +468,20 @@ class CHPPXml(CHPPBase):
399
468
  raise ValueError("'stats_type' argument must be None, "
400
469
  "or equal to 'MyArena' or 'OtherArenas'")
401
470
 
471
+ def xml_avatars(
472
+ self,
473
+ action_type: str = None,
474
+ team_id: int = None,
475
+ **kwargs,
476
+ ) -> avatars.Avatars:
477
+
478
+ return avatars.Avatars(
479
+ chpp=self,
480
+ action_type=action_type,
481
+ team_id=team_id,
482
+ **kwargs,
483
+ )
484
+
402
485
  def xml_challenges(
403
486
  self, action_type: str = 'view', team_id: Optional[int] = None,
404
487
  is_weekend_friendly: int = 0, suggested_team_ids: str = None,
@@ -29,11 +29,12 @@ class HTTeam(td.RequestTeamDetails, td.TeamItem, BaseHTTeam):
29
29
  league_unit: 'HTTeamLeagueUnit' = HTProxyField(td.TeamItem, 'league_level_unit')
30
30
  youth_team: 'HTTeamYouthTeam' = HTProxyField(td.TeamItem)
31
31
 
32
- def _pre_init(self, team_id=None, **kwargs):
32
+ def __init__(self, team_id=None, **kwargs):
33
33
  if team_id is not None:
34
34
  self.XML_FILTER = f".[TeamID='{team_id}']/"
35
35
  else:
36
36
  self.XML_FILTER = ".[IsPrimaryClub='True']/"
37
+ super().__init__(team_id=team_id, **kwargs)
37
38
 
38
39
  @property
39
40
  def is_bot(self) -> bool:
@@ -22,18 +22,19 @@ class MetaHTModel(type):
22
22
  dict_['_ht_fields'] = dict()
23
23
  dict_['_ht_init_vars'] = dict()
24
24
 
25
+ # Inherit _ht_fields and _ht_init_vars attributes from HTModel ancestors
25
26
  for b in bases:
26
27
  if issubclass(b, HTModel):
27
28
  dict_['_ht_fields'].update(b.__dict__['_ht_fields'])
28
29
  dict_['_ht_init_vars'].update(b.__dict__['_ht_init_vars'])
29
30
 
31
+ # Allow _ht_fields attributes and _ht_init_vars attributes to be overridden
32
+ # Remove then add to ensure that overridden attributes are at the end of the dict
30
33
  for attr_name, attr_value in dict_.items():
31
34
  if isinstance(attr_value, HTBaseField):
32
- # Remove then add to ensure that overridden attributes are at the end
33
35
  dict_['_ht_fields'].pop(attr_name, None)
34
36
  dict_['_ht_fields'][attr_name] = attr_value
35
37
  if isinstance(attr_value, HTInitVar):
36
- # Remove then add to ensure that overridden attributes are at the end
37
38
  dict_['_ht_init_vars'].pop(attr_name, None)
38
39
  dict_['_ht_init_vars'][attr_name] = attr_value
39
40
 
@@ -53,11 +54,17 @@ class HTModel(metaclass=MetaHTModel):
53
54
 
54
55
  @classmethod
55
56
  def is_optional_attrib(cls, attrib: str) -> bool:
57
+ """
58
+ Check if an attribute is optional according to its typehint
59
+ """
56
60
  typehint = get_type_hints(cls).get(attrib)
57
61
  return get_origin(typehint) is Union and type(None) in get_args(typehint)
58
62
 
59
63
  @classmethod
60
64
  def get_type(cls, attrib: str) -> Any:
65
+ """
66
+ Return attribute type from its typehint
67
+ """
61
68
  typehint = get_type_hints(cls).get(attrib)
62
69
 
63
70
  _type = typehint
@@ -70,6 +77,9 @@ class HTModel(metaclass=MetaHTModel):
70
77
 
71
78
  @classmethod
72
79
  def get_item_type(cls, attrib: str) -> Any:
80
+ """
81
+ Return item type if attribute's type is a list
82
+ """
73
83
  if cls.get_type(attrib) is not list:
74
84
  return None
75
85
 
@@ -98,8 +108,15 @@ class HTModel(metaclass=MetaHTModel):
98
108
  suppl_attrs: dict = None,
99
109
  **kwargs,
100
110
  ):
111
+ """
112
+ Instantiate a new HTModel object
101
113
 
102
- self._pre_init(**kwargs)
114
+ :param chpp: a CHPPBase object instantiated with credentials to connect to CHPP API
115
+ :param data: data to proceed (if given, no request is sent to CHPP API
116
+ :param version: xml file version to fetch
117
+ :param xml_prefix: default prefix added to tag names used to parse xml data
118
+ :param suppl_attrs: attributes dynamically added to the instance
119
+ """
103
120
 
104
121
  if not isinstance(chpp, _chpp.CHPPBase):
105
122
  raise ValueError("chpp must be a CHPP instance")
@@ -114,23 +131,27 @@ class HTModel(metaclass=MetaHTModel):
114
131
  self._data = data
115
132
  self._url = ''
116
133
  self._requests_args = dict()
134
+
117
135
  self.version = (HTVersion(version)
118
136
  if version is not None
119
137
  else HTVersion(self.LAST_VERSION))
120
138
  self.xml_prefix = xml_prefix if xml_prefix is not None else self.XML_PREFIX
121
139
 
140
+ # Dynamically create supplementary attributes
122
141
  if suppl_attrs is not None:
123
142
  for attr_name, attr_value in suppl_attrs.items():
124
143
  setattr(self, attr_name, attr_value)
125
144
 
126
- # if data is not given, fetch data on Hattrick
145
+ # if data is None, fetch data on Hattrick
127
146
  if self._data is None:
128
147
  self._fetch(version, **kwargs)
129
148
 
149
+ # Once data is obtained, transform HTField to actual values
130
150
  self._transform_fields()
131
151
 
132
152
  def _fetch(self, version, **kwargs):
133
153
 
154
+ # data is fetched using ht_init_vars attribute as query parameters
134
155
  for attr, ht_init_var in self._ht_init_vars.items():
135
156
 
136
157
  ht_init_var.value = kwargs.get(ht_init_var.init_arg, None)
@@ -141,6 +162,7 @@ class HTModel(metaclass=MetaHTModel):
141
162
  elif ht_init_var.value is None:
142
163
  ht_init_var.value = ht_init_var.default
143
164
 
165
+ # query parameters are parsed according to their typehints before requesting
144
166
  if ht_init_var.value is not None:
145
167
 
146
168
  type_ = self.get_type(attr)
@@ -155,6 +177,7 @@ class HTModel(metaclass=MetaHTModel):
155
177
 
156
178
  setattr(self, attr, ht_init_var.value)
157
179
 
180
+ # self._data is filled with the file returned by the API call
158
181
  self._data = self._chpp.request(file=self.SOURCE_FILE,
159
182
  version=self.version.as_string,
160
183
  **self._requests_args,
@@ -168,6 +191,8 @@ class HTModel(metaclass=MetaHTModel):
168
191
 
169
192
  proxy_path = ''
170
193
 
194
+ # HTProxyField allow to reference a value according to another HTField attribute
195
+ # (instead of giving the actual xml path)
171
196
  if isinstance(field, HTProxyField):
172
197
  field: HTProxyField
173
198
 
@@ -208,7 +233,7 @@ class HTModel(metaclass=MetaHTModel):
208
233
  suppl_attrs = {k: getattr(self, v) for k, v in field.suppl_attrs.items()}
209
234
 
210
235
  # instance attribute set to transformed value
211
- # according to type hint
236
+ # according to typehint
212
237
  if f_type is list:
213
238
 
214
239
  if xml_node is None:
@@ -269,6 +294,8 @@ class HTModel(metaclass=MetaHTModel):
269
294
  field_name,
270
295
  HTXml.opt_ht_datetime_from_text(xml_node, attrib=field.attrib))
271
296
 
297
+ # if the type is HTModel class, attribute will refer
298
+ # to another HTModel object
272
299
  elif issubclass(f_type, HTModel):
273
300
  setattr(self, field_name, f_type(chpp=self._chpp,
274
301
  data=xml_node,
@@ -287,14 +314,10 @@ class HTModel(metaclass=MetaHTModel):
287
314
  field: HTAliasField
288
315
  setattr(self, field_name, getattr(self, field.target))
289
316
 
290
- def _pre_init(self, **kwargs):
317
+ def _save_as_xml(self, path: pathlib.Path = None, filename: str = None):
291
318
  """
292
- hook to make some stuff at the beginning of __init__ process
293
-
319
+ Save self._data to a xml file
294
320
  """
295
-
296
- def _save_as_xml(self, path: pathlib.Path = None, filename: str = None):
297
-
298
321
  if path is None:
299
322
  path = pathlib.Path.cwd()
300
323
 
@@ -0,0 +1,137 @@
1
+ from datetime import datetime
2
+ from typing import Optional, List
3
+
4
+ from pychpp.models.ht_field import HTField
5
+ from pychpp.models.ht_init_var import HTInitVar
6
+ from pychpp.models.ht_model import HTModel
7
+
8
+
9
+ class RequestAllianceDetails(HTModel):
10
+ """
11
+ Alliance Details - Base request arguments
12
+ """
13
+ SOURCE_FILE = 'alliancedetails'
14
+ LAST_VERSION = '1.5'
15
+
16
+ _r_action_type: Optional[str] = HTInitVar('actionType', init_arg='action_type')
17
+ _r_alliance_id: int = HTInitVar('allianceID', init_arg='alliance_id')
18
+ _r_subset: Optional[int] = HTInitVar('subset', init_arg='subset')
19
+
20
+
21
+ class BaseAllianceDetails(RequestAllianceDetails):
22
+ """
23
+ Alliance Details
24
+ """
25
+ user_supporter_tier: str = HTField('UserSupporterTier')
26
+ action_type: str = HTField('ActionType')
27
+
28
+
29
+ class AllianceDetailsView(BaseAllianceDetails):
30
+ """
31
+ Alliance Details - View
32
+ """
33
+ alliance: 'AllianceView' = HTField('Alliance')
34
+
35
+
36
+ class AllianceDetailsRoles(BaseAllianceDetails):
37
+ """
38
+ Alliance Details - Roles
39
+ """
40
+ alliance: 'AllianceRoles' = HTField('Alliance')
41
+
42
+
43
+ class BaseAlliance(HTModel):
44
+ """
45
+ Alliance Details -> Base Alliance
46
+ """
47
+ id: int = HTField('AllianceID')
48
+ name: str = HTField('AllianceName')
49
+
50
+
51
+ class AllianceView(BaseAlliance):
52
+ """
53
+ Alliance Details - View -> Alliance
54
+ """
55
+ abbreviation: str = HTField('Abbreviation')
56
+ description: str = HTField('Description')
57
+ logo_url: str = HTField('LogoURL')
58
+ top_role: str = HTField('TopRole')
59
+ top_user_id: int = HTField('TopUserID')
60
+ top_login_name: str = HTField('TopLoginname')
61
+ creation_date: datetime = HTField('CreationDate')
62
+ home_page_url: str = HTField('HomePageURL')
63
+ number_of_members: int = HTField('NumberOfMembers')
64
+ languages: List['AllianceLanguageItem'] = HTField('Languages', items='Language')
65
+ message: Optional[str] = HTField('Message')
66
+ rules: Optional[str] = HTField('Rules')
67
+ user_role: Optional['AllianceUserRole'] = HTField('UserRole')
68
+
69
+
70
+ class AllianceLanguageItem(HTModel):
71
+ """
72
+ Alliance Details - View -> Alliance -> Languages -> Language item
73
+ """
74
+ id: int = HTField('LanguageID')
75
+ name: str = HTField('LanguageName')
76
+
77
+
78
+ class AllianceUserRole(HTModel):
79
+ """
80
+ Alliance Details - View -> Alliance -> User Role
81
+ """
82
+ id: int = HTField('RoleId')
83
+ name: str = HTField('RoleName')
84
+
85
+
86
+ class AllianceRoles(HTModel):
87
+ """
88
+ Alliance Details - Roles -> Alliance
89
+ """
90
+ roles: List['AllianceRoleItem'] = HTField('Roles', items='Role', xml_prefix='Role')
91
+
92
+
93
+ class AllianceRoleItem(HTModel):
94
+ """
95
+ Alliance Details - Roles -> Alliance -> Roles -> Role item
96
+ """
97
+ id: int = HTField('Id')
98
+ name: str = HTField('Name')
99
+ rank: int = HTField('Rank')
100
+ member_count: int = HTField('MemberCount')
101
+ max_members: int = HTField('MaxMembers')
102
+ request_type: int = HTField('RequestType')
103
+ description: str = HTField('RoleDescription')
104
+
105
+
106
+ class AllianceDetailsMembers(BaseAllianceDetails):
107
+ """
108
+ Alliance Details - Members
109
+ """
110
+ alliance: 'AllianceMembers' = HTField('Alliance')
111
+
112
+
113
+ class AllianceMembers(BaseAlliance):
114
+ """
115
+ Alliance Details - Members -> Alliance
116
+ """
117
+ members: List['AllianceMemberItem'] = HTField('Members', items='Member')
118
+
119
+
120
+ class AllianceDetailsMembersSubset(BaseAllianceDetails):
121
+ """
122
+ Alliance Details - Members Subset
123
+ """
124
+ list_subset: str = HTField('ListSubset')
125
+ members: List['AllianceMemberItem']
126
+
127
+
128
+ class AllianceMemberItem(HTModel):
129
+ """
130
+ Alliance Details - Members/Members Subset -> Alliance -> Members -> Member item
131
+ """
132
+ user_id: int = HTField('UserID')
133
+ login_name: str = HTField('Loginname')
134
+ role_id: int = HTField('RoleId')
135
+ role_name: str = HTField('RoleName')
136
+ is_online: bool = HTField('IsOnline')
137
+ membership_date: datetime = HTField('MembershipDate')
@@ -0,0 +1,36 @@
1
+ from typing import List, Optional
2
+
3
+ from pychpp.models.ht_model import HTField, HTInitVar, HTModel
4
+
5
+
6
+ class RequestAlliances(HTModel):
7
+ """
8
+ Alliances - Request arguments
9
+ """
10
+ SOURCE_FILE = "alliances"
11
+ LAST_VERSION = "1.4"
12
+
13
+ _r_search_type: Optional[int] = HTInitVar('searchType', init_arg='search_type')
14
+ _r_search_language_id: Optional[int] = HTInitVar('searchLanguageID',
15
+ init_arg='search_language_id')
16
+ _r_search_for: str = HTInitVar('searchFor', init_arg='search_for')
17
+ _r_page_index: Optional[int] = HTInitVar('pageIndex', init_arg='page_index')
18
+
19
+
20
+ class Alliances(RequestAlliances):
21
+ """
22
+ Alliances
23
+ """
24
+ pages: int = HTField('Pages')
25
+ page_index: int = HTField('PageIndex')
26
+ user_supporter_tier: str = HTField('UserSupporterTier')
27
+ alliances: List['AllianceItem'] = HTField('Alliances', items='Alliance', xml_prefix='Alliance')
28
+
29
+
30
+ class AllianceItem(HTModel):
31
+ """
32
+ Alliances -> Alliances -> Alliance item
33
+ """
34
+ id: int = HTField('ID')
35
+ name: str = HTField('Name')
36
+ description: str = HTField('Description')
@@ -0,0 +1,56 @@
1
+ from typing import List, Optional
2
+
3
+ from pychpp.models.ht_field import HTField
4
+ from pychpp.models.ht_init_var import HTInitVar
5
+ from pychpp.models.ht_model import HTModel
6
+
7
+
8
+ class RequestAvatars(HTModel):
9
+ """
10
+ Avatars - Request arguments
11
+ """
12
+ SOURCE_FILE = 'avatars'
13
+ LAST_VERSION = '1.1'
14
+
15
+ _r_action_type: Optional[str] = HTInitVar('actionType', init_arg='action_type')
16
+ _r_team_id: Optional[int] = HTInitVar('teamId', init_arg='team_id')
17
+
18
+
19
+ class Avatars(RequestAvatars):
20
+ """
21
+ Avatars
22
+ """
23
+ team: 'Team' = HTField('Team')
24
+
25
+
26
+ class Team(HTModel):
27
+ """
28
+ Avatars -> Team
29
+ """
30
+ id: int = HTField('TeamId')
31
+ players: List['PlayerItem'] = HTField('Players', items='Player')
32
+
33
+
34
+ class PlayerItem(HTModel):
35
+ """
36
+ Avatars -> Team -> Players -> Player item
37
+ """
38
+ id: int = HTField('PlayerID')
39
+ avatar: 'Avatar' = HTField('Avatar')
40
+
41
+
42
+ class Avatar(HTModel):
43
+ """
44
+ Avatars -> Team -> Players -> Player item -> Avatar
45
+ """
46
+ background_image: str = HTField('BackgroundImage')
47
+ layers: List['LayerItem'] = HTField('.', items='Layer')
48
+
49
+
50
+ class LayerItem(HTModel):
51
+ """
52
+ Avatars -> Team -> Players -> Player item -> Avatar -> Layer
53
+ """
54
+ x: int = HTField('.', attrib='x')
55
+ y: int = HTField('.', attrib='y')
56
+ image: str = HTField('Image')
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pychpp"
3
- version = "0.4.0b2"
3
+ version = "0.4.1"
4
4
  description = "framework created to use the API provided by the online game Hattrick"
5
5
  license = "Apache-2.0"
6
6
  authors = ["Pierre Gobin <p.dev@gobin.cc>"]
@@ -15,7 +15,7 @@ pytz = "^2024.2"
15
15
  Werkzeug = "^2.2.2"
16
16
 
17
17
  [tool.poetry.group.dev.dependencies]
18
- pytest = "^7.2.0"
18
+ pytest = "^8.3.3"
19
19
  pytest-dotenv = "^0.5.2"
20
20
  flake8 = "^5.0.4"
21
21
 
File without changes
File without changes
File without changes