pychpp 0.4.0b2__tar.gz → 0.4.2__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 (73) hide show
  1. {pychpp-0.4.0b2 → pychpp-0.4.2}/PKG-INFO +17 -7
  2. {pychpp-0.4.0b2 → pychpp-0.4.2}/README.md +15 -6
  3. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/chpp.py +134 -1
  4. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_team.py +2 -1
  5. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/ht_model.py +34 -11
  6. pychpp-0.4.2/pychpp/models/xml/alliance_details.py +137 -0
  7. pychpp-0.4.2/pychpp/models/xml/alliances.py +36 -0
  8. pychpp-0.4.2/pychpp/models/xml/avatars.py +56 -0
  9. pychpp-0.4.2/pychpp/models/xml/bookmarks.py +36 -0
  10. pychpp-0.4.2/pychpp/models/xml/club.py +54 -0
  11. pychpp-0.4.2/pychpp/models/xml/current_bids.py +62 -0
  12. pychpp-0.4.2/pychpp/models/xml/economy.py +66 -0
  13. pychpp-0.4.2/pychpp/models/xml/fans.py +74 -0
  14. pychpp-0.4.2/pychpp/models/xml/hof_players.py +40 -0
  15. {pychpp-0.4.0b2 → pychpp-0.4.2}/pyproject.toml +2 -2
  16. {pychpp-0.4.0b2 → pychpp-0.4.2}/LICENSE +0 -0
  17. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/__init__.py +0 -0
  18. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/fixtures/__init__.py +0 -0
  19. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/fixtures/ht_datetime.py +0 -0
  20. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/fixtures/ht_error.py +0 -0
  21. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/__init__.py +0 -0
  22. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/__init__.py +0 -0
  23. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/__init__.py +0 -0
  24. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_arena.py +0 -0
  25. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_country.py +0 -0
  26. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_league.py +0 -0
  27. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_league_unit.py +0 -0
  28. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_match.py +0 -0
  29. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_player.py +0 -0
  30. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_region.py +0 -0
  31. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_team.py +0 -0
  32. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/base/ht_user.py +0 -0
  33. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_arena.py +0 -0
  34. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_challenge.py +0 -0
  35. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_league.py +0 -0
  36. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_league_unit.py +0 -0
  37. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_match.py +0 -0
  38. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_match_lineup.py +0 -0
  39. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_matches_archive.py +0 -0
  40. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_player.py +0 -0
  41. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_region.py +0 -0
  42. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_transfer_history.py +0 -0
  43. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_user.py +0 -0
  44. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_youth_player.py +0 -0
  45. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/custom/ht_youth_team.py +0 -0
  46. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/ht_field.py +0 -0
  47. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/ht_init_var.py +0 -0
  48. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/ht_version.py +0 -0
  49. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/ht_xml.py +0 -0
  50. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/__init__.py +0 -0
  51. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/achievements.py +0 -0
  52. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/arena_details.py +0 -0
  53. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/challenges.py +0 -0
  54. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/cup_matches.py +0 -0
  55. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/league_details.py +0 -0
  56. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/league_fixtures.py +0 -0
  57. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/manager_compendium.py +0 -0
  58. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/match_details.py +0 -0
  59. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/match_lineup.py +0 -0
  60. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/matches_archive.py +0 -0
  61. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/national_team_details.py +0 -0
  62. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/national_teams.py +0 -0
  63. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/player_details.py +0 -0
  64. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/players.py +0 -0
  65. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/region_details.py +0 -0
  66. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/team_details.py +0 -0
  67. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/training.py +0 -0
  68. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/transfers_team.py +0 -0
  69. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/world_cup.py +0 -0
  70. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/world_details.py +0 -0
  71. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/youth_player_details.py +0 -0
  72. {pychpp-0.4.0b2 → pychpp-0.4.2}/pychpp/models/xml/youth_player_list.py +0 -0
  73. {pychpp-0.4.0b2 → pychpp-0.4.2}/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.2
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)
@@ -133,14 +134,14 @@ However, for more advanced use, it is also possible to customize the framework's
133
134
 
134
135
  For example, if you need to perform a query on the arenadetails.xml file, but in reality only need the Arena/ArenaID, Arena/ArenaName and Arena/ArenaImage data, one way to proceed is to create a custom class inheriting from the RequestArenaDetails class, and use HTProxyField as follows:
135
136
  ```python
136
- from pychpp.models.xml.arena_details import RequestArenaDetails, ArenaDetails
137
+ from pychpp.models.xml.arena_details import RequestArenaDetailsDefault, ArenaDetailsDefault
137
138
  from pychpp.models.ht_field import HTProxyField
138
139
 
139
140
 
140
- class MyCustomArenaClass(RequestArenaDetails):
141
- id: int = HTProxyField(ArenaDetails)
142
- name: str = HTProxyField(ArenaDetails)
143
- image: str = HTProxyField(ArenaDetails)
141
+ class MyCustomArenaClass(RequestArenaDetailsDefault):
142
+ id: int = HTProxyField(ArenaDetailsDefault)
143
+ name: str = HTProxyField(ArenaDetailsDefault)
144
+ image: str = HTProxyField(ArenaDetailsDefault)
144
145
  ```
145
146
 
146
147
  Then, to use this new class:
@@ -164,16 +165,25 @@ 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
+ ![32/57](https://progress-bar.xyz/56/?title=32%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` |
178
+ | Avatars | `avatars.xml` |
179
+ | Bookmarks | `bookmarks.xml` |
175
180
  | Challenges | `challenges.xml` |
181
+ | Club | `club.xml` |
176
182
  | CupMatches | `cupmatches.xml` |
183
+ | CurrentBids | `currentbids.xml` |
184
+ | Economy | `economy.xml` |
185
+ | Fans | `fans.xml` |
186
+ | HallOfFamePlayers | `hofplayers.xml` |
177
187
  | LeagueDetails | `leaguedetails.xml` |
178
188
  | LeagueFixtures | `leaguefixtures.xml` |
179
189
  | ManagerCompendium | `managercompendium.xml` |
@@ -112,14 +112,14 @@ However, for more advanced use, it is also possible to customize the framework's
112
112
 
113
113
  For example, if you need to perform a query on the arenadetails.xml file, but in reality only need the Arena/ArenaID, Arena/ArenaName and Arena/ArenaImage data, one way to proceed is to create a custom class inheriting from the RequestArenaDetails class, and use HTProxyField as follows:
114
114
  ```python
115
- from pychpp.models.xml.arena_details import RequestArenaDetails, ArenaDetails
115
+ from pychpp.models.xml.arena_details import RequestArenaDetailsDefault, ArenaDetailsDefault
116
116
  from pychpp.models.ht_field import HTProxyField
117
117
 
118
118
 
119
- class MyCustomArenaClass(RequestArenaDetails):
120
- id: int = HTProxyField(ArenaDetails)
121
- name: str = HTProxyField(ArenaDetails)
122
- image: str = HTProxyField(ArenaDetails)
119
+ class MyCustomArenaClass(RequestArenaDetailsDefault):
120
+ id: int = HTProxyField(ArenaDetailsDefault)
121
+ name: str = HTProxyField(ArenaDetailsDefault)
122
+ image: str = HTProxyField(ArenaDetailsDefault)
123
123
  ```
124
124
 
125
125
  Then, to use this new class:
@@ -143,16 +143,25 @@ 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
+ ![32/57](https://progress-bar.xyz/56/?title=32%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` |
156
+ | Avatars | `avatars.xml` |
157
+ | Bookmarks | `bookmarks.xml` |
154
158
  | Challenges | `challenges.xml` |
159
+ | Club | `club.xml` |
155
160
  | CupMatches | `cupmatches.xml` |
161
+ | CurrentBids | `currentbids.xml` |
162
+ | Economy | `economy.xml` |
163
+ | Fans | `fans.xml` |
164
+ | HallOfFamePlayers | `hofplayers.xml` |
156
165
  | LeagueDetails | `leaguedetails.xml` |
157
166
  | LeagueFixtures | `leaguefixtures.xml` |
158
167
  | ManagerCompendium | `managercompendium.xml` |
@@ -11,7 +11,9 @@ 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, bookmarks, club, current_bids, economy,
16
+ fans, hof_players)
15
17
  from pychpp.models.custom import (ht_team, ht_arena, ht_user, ht_region, ht_youth_team, ht_player,
16
18
  ht_league_unit, ht_youth_player, ht_league, ht_matches_archive,
17
19
  ht_match, ht_challenge, ht_match_lineup, ht_transfer_history)
@@ -371,6 +373,74 @@ class CHPPXml(CHPPBase):
371
373
 
372
374
  return achievements.Achievements(chpp=self, user_id=user_id)
373
375
 
376
+ def xml_alliances(
377
+ self,
378
+ search_for: str,
379
+ search_type: int = None,
380
+ search_language_id: int = None,
381
+ page_index: int = None,
382
+ **kwargs,
383
+ ) -> alliances.Alliances:
384
+
385
+ return alliances.Alliances(
386
+ chpp=self,
387
+ search_type=search_type,
388
+ search_for=search_for,
389
+ search_language_id=search_language_id,
390
+ page_index=page_index,
391
+ **kwargs,
392
+ )
393
+
394
+ def xml_alliance_details(
395
+ self,
396
+ action_type: str = 'view',
397
+ subset: int = None,
398
+ alliance_id: int = None,
399
+ **kwargs,
400
+ ) -> Union[alliance_details.AllianceDetailsView,
401
+ alliance_details.AllianceDetailsRoles,
402
+ alliance_details.AllianceDetailsMembers,
403
+ alliance_details.AllianceDetailsMembersSubset,
404
+ ]:
405
+
406
+ if action_type == 'view':
407
+ return alliance_details.AllianceDetailsView(
408
+ chpp=self,
409
+ action_type=action_type,
410
+ alliance_id=alliance_id,
411
+ **kwargs,
412
+ )
413
+
414
+ elif action_type == 'roles':
415
+ return alliance_details.AllianceDetailsRoles(
416
+ chpp=self,
417
+ action_type=action_type,
418
+ alliance_id=alliance_id,
419
+ **kwargs,
420
+ )
421
+
422
+ elif action_type == 'members':
423
+ return alliance_details.AllianceDetailsMembers(
424
+ chpp=self,
425
+ action_type=action_type,
426
+ alliance_id=alliance_id,
427
+ **kwargs,
428
+ )
429
+
430
+ elif action_type == 'membersSubset':
431
+ return alliance_details.AllianceDetailsMembersSubset(
432
+ chpp=self,
433
+ action_type=action_type,
434
+ subset=subset,
435
+ alliance_id=alliance_id,
436
+ **kwargs,
437
+ )
438
+
439
+ else:
440
+ ValueError("'action_type' argument must be "
441
+ "equal to 'view', 'roles', "
442
+ "'members' or 'membersSubset'")
443
+
374
444
  def xml_arena_details(
375
445
  self, stats_type: str = None, arena_id: int = None, team_id: int = None,
376
446
  match_type: str = None, first_date: datetime = None,
@@ -399,6 +469,31 @@ class CHPPXml(CHPPBase):
399
469
  raise ValueError("'stats_type' argument must be None, "
400
470
  "or equal to 'MyArena' or 'OtherArenas'")
401
471
 
472
+ def xml_avatars(
473
+ self,
474
+ action_type: str = None,
475
+ team_id: int = None,
476
+ **kwargs,
477
+ ) -> avatars.Avatars:
478
+
479
+ return avatars.Avatars(
480
+ chpp=self,
481
+ action_type=action_type,
482
+ team_id=team_id,
483
+ **kwargs,
484
+ )
485
+
486
+ def xml_bookmarks(
487
+ self, bookmark_type_id: int = None,
488
+ **kwargs,
489
+ ) -> bookmarks.Bookmarks:
490
+
491
+ return bookmarks.Bookmarks(
492
+ chpp=self,
493
+ bookmark_type_id=bookmark_type_id,
494
+ **kwargs,
495
+ )
496
+
402
497
  def xml_challenges(
403
498
  self, action_type: str = 'view', team_id: Optional[int] = None,
404
499
  is_weekend_friendly: int = 0, suggested_team_ids: str = None,
@@ -459,6 +554,11 @@ class CHPPXml(CHPPBase):
459
554
  "'view', 'challengeable', 'challenge', "
460
555
  "'accept', 'decline' or 'withdraw'")
461
556
 
557
+ def xml_club(self, team_id: int = None, **kwargs,
558
+ ) -> club.Club:
559
+
560
+ return club.Club(chpp=self, team_id=team_id, **kwargs)
561
+
462
562
  def xml_cup_matches(
463
563
  self, cup_id: int, season: int = None, cup_round: int = None,
464
564
  start_after_match_id: int = None, **kwargs,
@@ -469,6 +569,39 @@ class CHPPXml(CHPPBase):
469
569
  start_after_match_id=start_after_match_id, **kwargs,
470
570
  )
471
571
 
572
+ def xml_current_bids(
573
+ self,
574
+ action_type: str = 'view',
575
+ team_id: int = None,
576
+ transfer_id: int = None,
577
+ tracking_type_id: int = None,
578
+ **kwargs,
579
+ ) -> current_bids.CurrentBids:
580
+
581
+ return current_bids.CurrentBids(
582
+ chpp=self,
583
+ action_type=action_type,
584
+ team_id=team_id,
585
+ transfer_id=transfer_id,
586
+ tracking_type_id=tracking_type_id,
587
+ **kwargs,
588
+ )
589
+
590
+ def xml_economy(self, team_id: int = None, **kwargs,
591
+ ) -> economy.Economy:
592
+
593
+ return economy.Economy(chpp=self, team_id=team_id, **kwargs)
594
+
595
+ def xml_fans(self, team_id: int = None, **kwargs,
596
+ ) -> fans.Fans:
597
+
598
+ return fans.Fans(chpp=self, team_id=team_id, **kwargs)
599
+
600
+ def xml_hof_players(self, team_id: int = None, **kwargs,
601
+ ) -> hof_players.HallOfFamePlayers:
602
+
603
+ return hof_players.HallOfFamePlayers(chpp=self, team_id=team_id, **kwargs)
604
+
472
605
  def xml_league_details(
473
606
  self, league_level_unit_id: int = None, **kwargs,
474
607
  ) -> league_details.LeagueDetails:
@@ -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')
@@ -0,0 +1,36 @@
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 RequestBookmarks(HTModel):
9
+ """
10
+ Bookmarks - Request arguments
11
+ """
12
+ SOURCE_FILE = 'bookmarks'
13
+ LAST_VERSION = '1.0'
14
+
15
+ _r_bookmark_type_id: Optional[int] = HTInitVar('bookmarkTypeID', init_arg='bookmark_type_id')
16
+
17
+
18
+ class Bookmarks(RequestBookmarks):
19
+ """
20
+ Bookmarks
21
+ """
22
+ bookmark_list: List['BookmarkItem'] = HTField('BookmarkList', items='Bookmark')
23
+
24
+
25
+ class BookmarkItem(HTModel):
26
+ """
27
+ Bookmarks -> Bookmark list -> Bookmark item
28
+ """
29
+ id: str = HTField('BookmarkID')
30
+ type_id: int = HTField('BookmarkTypeID')
31
+ text: str = HTField('Text')
32
+ text_2: Optional[str] = HTField('Text2')
33
+ object_id: str = HTField('ObjectID')
34
+ object_id_2: Optional[str] = HTField('ObjectID2')
35
+ object_id_3: Optional[str] = HTField('ObjectID3')
36
+ comment: str = HTField('Comment')
@@ -0,0 +1,54 @@
1
+ from typing import 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 RequestClub(HTModel):
9
+ """
10
+ Club - Request arguments
11
+ """
12
+ SOURCE_FILE = 'club'
13
+ LAST_VERSION = '1.5'
14
+
15
+ _r_team_id: Optional[int] = HTInitVar('teamId', init_arg='team_id')
16
+
17
+
18
+ class Club(RequestClub):
19
+ """
20
+ Club
21
+ """
22
+ team: 'Team' = HTField('Team')
23
+
24
+
25
+ class Team(HTModel):
26
+ """
27
+ Club -> Team
28
+ """
29
+ id: int = HTField('TeamID')
30
+ name: str = HTField('TeamName')
31
+ staff: 'TeamStaff' = HTField('Staff')
32
+ youth_squad: 'TeamYouthSquad' = HTField('YouthSquad')
33
+
34
+
35
+ class TeamStaff(HTModel):
36
+ """
37
+ Club -> Team -> Staff
38
+ """
39
+ assistant_trainer_levels: int = HTField('AssistantTrainerLevels')
40
+ financial_director_levels: int = HTField('FinancialDirectorLevels')
41
+ form_coach_levels: int = HTField('FormCoachLevels')
42
+ medic_levels: int = HTField('MedicLevels')
43
+ spokesperson_levels: int = HTField('SpokespersonLevels')
44
+ sport_psychologist_levels: int = HTField('SportPsychologistLevels')
45
+ tactical_assistant_levels: int = HTField('TacticalAssistantLevels')
46
+
47
+
48
+ class TeamYouthSquad(HTModel):
49
+ """
50
+ Club -> Team -> Youth Squad
51
+ """
52
+ investment: int = HTField('Investment')
53
+ has_promoted: bool = HTField('HasPromoted')
54
+ youth_level: int = HTField('YouthLevel')
@@ -0,0 +1,62 @@
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 RequestCurrentBids(HTModel):
10
+ """
11
+ Current Bids - Request arguments
12
+ """
13
+ SOURCE_FILE = 'currentbids'
14
+ LAST_VERSION = '1.0'
15
+
16
+ _r_action_type: Optional[str] = HTInitVar('actionType', init_arg='action_type')
17
+ _r_team_id: Optional[int] = HTInitVar('teamId', init_arg='team_id')
18
+ _r_transfer_id: Optional[int] = HTInitVar('transferId', init_arg='transfer_id')
19
+ _r_tracking_type_id: Optional[int] = HTInitVar('trackingTypeId', init_arg='tracking_type_id')
20
+
21
+
22
+ class CurrentBids(RequestCurrentBids):
23
+ """
24
+ Current Bids
25
+ """
26
+ team_id: int = HTField('TeamId')
27
+ selling_bids: Optional[List['BidItem']] = HTField('BidItems[@TrackingTypeID="1"]',
28
+ items='BidItem')
29
+ buying_bids: Optional[List['BidItem']] = HTField('BidItems[@TrackingTypeID="2"]',
30
+ items='BidItem')
31
+ mother_club_bids: Optional[List['BidItem']] = HTField('BidItems[@TrackingTypeID="3"]',
32
+ items='BidItem')
33
+ previous_team_bids: Optional[List['BidItem']] = HTField('BidItems[@TrackingTypeID="4"]',
34
+ items='BidItem')
35
+ hot_listed_bids: Optional[List['BidItem']] = HTField('BidItems[@TrackingTypeID="5"]',
36
+ items='BidItem')
37
+ losing_bids: Optional[List['BidItem']] = HTField('BidItems[@TrackingTypeID="8"]',
38
+ items='BidItem')
39
+ finished_bids: Optional[List['BidItem']] = HTField('BidItems[@TrackingTypeID="9"]',
40
+ items='BidItem')
41
+ prospects_bids: Optional[List['BidItem']] = HTField('BidItems[@TrackingTypeID="10"]',
42
+ items='BidItem')
43
+
44
+
45
+ class BidItem(HTModel):
46
+ """
47
+ Current Bids -> Bids -> Bid item
48
+ """
49
+ transfer_id: int = HTField('TransferId')
50
+ player_id: int = HTField('PlayerId')
51
+ player_name: str = HTField('PlayerName')
52
+ highest_bid: 'HighestBid' = HTField('HighestBid')
53
+ deadline: datetime = HTField('Deadline')
54
+
55
+
56
+ class HighestBid(HTModel):
57
+ """
58
+ Current Bids -> Bids -> Bid item -> Highest Bid
59
+ """
60
+ amount: int = HTField('Amount')
61
+ team_id: int = HTField('TeamId')
62
+ team_name: str = HTField('TeamName')
@@ -0,0 +1,66 @@
1
+ from typing import 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 RequestEconomy(HTModel):
9
+ """
10
+ Economy - Request arguments
11
+ """
12
+ SOURCE_FILE = 'economy'
13
+ LAST_VERSION = '1.4'
14
+
15
+ _r_team_id: Optional[int] = HTInitVar('teamId', init_arg='team_id')
16
+
17
+
18
+ class Economy(RequestEconomy):
19
+ """
20
+ Economy
21
+ """
22
+ team: 'Team' = HTField('Team')
23
+
24
+
25
+ class Team(HTModel):
26
+ """
27
+ Economy -> Team
28
+ """
29
+ id: int = HTField('TeamID')
30
+ name: str = HTField('TeamName')
31
+ cash: int = HTField('Cash')
32
+ expected_cash: int = HTField('ExpectedCash')
33
+ sponsors_popularity: Optional[int] = HTField('SponsorsPopularity')
34
+ supporters_popularity: Optional[int] = HTField('SupportersPopularity')
35
+ fan_club_size: int = HTField('FanClubSize')
36
+ income_spectators: int = HTField('IncomeSpectators')
37
+ income_sponsors: int = HTField('IncomeSponsors')
38
+ income_sponsors_bonus: int = HTField('IncomeSponsorBonuses')
39
+ income_financial: int = HTField('IncomeFinancial')
40
+ income_sold_players: int = HTField('IncomeSoldPlayers')
41
+ income_sold_players_commission: int = HTField('IncomeSoldPlayersCommission')
42
+ income_sum: int = HTField('IncomeSum')
43
+ costs_arena: int = HTField('CostsArena')
44
+ costs_players: int = HTField('CostsPlayers')
45
+ costs_financial: int = HTField('CostsFinancial')
46
+ costs_bought_players: int = HTField('CostsBoughtPlayers')
47
+ costs_arena_building: int = HTField('CostsArenaBuilding')
48
+ costs_staff: int = HTField('CostsStaff')
49
+ costs_youth: int = HTField('CostsYouth')
50
+ costs_sum: int = HTField('CostsSum')
51
+ expected_weeks_total: int = HTField('ExpectedWeeksTotal')
52
+ last_income_spectators: int = HTField('LastIncomeSpectators')
53
+ last_income_sponsors: int = HTField('LastIncomeSponsors')
54
+ last_income_financial: int = HTField('LastIncomeFinancial')
55
+ last_income_sold_players: int = HTField('LastIncomeSoldPlayers')
56
+ last_income_sold_players_commission: int = HTField('LastIncomeSoldPlayersCommission')
57
+ last_income_sum: int = HTField('LastIncomeSum')
58
+ last_costs_arena: int = HTField('LastCostsArena')
59
+ last_costs_players: int = HTField('LastCostsPlayers')
60
+ last_costs_financial: int = HTField('LastCostsFinancial')
61
+ last_costs_bought_players: int = HTField('LastCostsBoughtPlayers')
62
+ last_costs_arena_building: int = HTField('LastCostsArenaBuilding')
63
+ last_costs_staff: int = HTField('LastCostsStaff')
64
+ last_costs_youth: int = HTField('LastCostsYouth')
65
+ last_costs_sum: int = HTField('LastCostsSum')
66
+ last_weeks_total: int = HTField('LastWeeksTotal')
@@ -0,0 +1,74 @@
1
+ from datetime import datetime
2
+ from typing import List, Optional
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 RequestFans(HTModel):
10
+ """
11
+ Fans - Request arguments
12
+ """
13
+ SOURCE_FILE = 'fans'
14
+ LAST_VERSION = '1.3'
15
+
16
+ _r_team_id: Optional[int] = HTInitVar('teamId', init_arg='team_id')
17
+
18
+
19
+ class Fans(RequestFans):
20
+ """
21
+ Fans
22
+ """
23
+ team: 'Team' = HTField('Team')
24
+
25
+
26
+ class Team(HTModel):
27
+ """
28
+ Fans -> Team
29
+ """
30
+ id: int = HTField('TeamID')
31
+ fan_club_id: int = HTField('FanclubId')
32
+ fan_club_name: str = HTField('FanclubName')
33
+ fan_mood: int = HTField('FanMood')
34
+ members: int = HTField('Members')
35
+ fan_season_expectation: int = HTField('FanSeasonExpectation')
36
+ played_matches: List['PlayedMatchItem'] = HTField('PlayedMatches', items='Match')
37
+ upcoming_matches: List['UpcomingMatchItem'] = HTField('UpcomingMatches', items='Match')
38
+
39
+
40
+ class BaseMatchItem(HTModel):
41
+ """
42
+ Fans -> Team -> Played/Upcoming matches -> Match item
43
+ """
44
+ id: int = HTField('MatchID')
45
+ home_team: 'BaseMatchItemTeam' = HTField('HomeTeam', xml_prefix='Home')
46
+ away_team: 'BaseMatchItemTeam' = HTField('AwayTeam', xml_prefix='Away')
47
+ date: datetime = HTField('MatchDate')
48
+ type: int = HTField('MatchType')
49
+ fan_match_expectation: int = HTField('FanMatchExpectation')
50
+
51
+
52
+ class BaseMatchItemTeam(HTModel):
53
+ """
54
+ Fans -> Team -> Played/Upcoming matches -> Match item -> Home/Away team
55
+ """
56
+ id: int = HTField('TeamID')
57
+ name: str = HTField('TeamName')
58
+
59
+
60
+ class PlayedMatchItem(BaseMatchItem):
61
+ """
62
+ Fans -> Team -> Played matches -> Match item
63
+ """
64
+ home_goals: int = HTField('HomeGoals')
65
+ away_goals: int = HTField('AwayGoals')
66
+ fan_mood_after_match: int = HTField('FanMoodAfterMatch')
67
+ weather: int = HTField('Weather')
68
+ sold_seats: int = HTField('SoldSeats')
69
+
70
+
71
+ class UpcomingMatchItem(BaseMatchItem):
72
+ """
73
+ Fans -> Team -> Upcoming matches -> Match item
74
+ """
@@ -0,0 +1,40 @@
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 RequestHallOfFamePlayers(HTModel):
10
+ """
11
+ Hall of Fame Players - Request arguments
12
+ """
13
+ SOURCE_FILE = 'hofplayers'
14
+ LAST_VERSION = '1.2'
15
+
16
+ _r_team_id: Optional[int] = HTInitVar('teamID', init_arg='team_id')
17
+
18
+
19
+ class HallOfFamePlayers(RequestHallOfFamePlayers):
20
+ """
21
+ Hall of Fame Players
22
+ """
23
+ players: Optional[List['PlayerItem']] = HTField('PlayerList', items='Player')
24
+
25
+
26
+ class PlayerItem(HTModel):
27
+ """
28
+ Hall of Fame Players -> Players -> Player item
29
+ """
30
+ id: int = HTField('PlayerId')
31
+ first_name: str = HTField('FirstName')
32
+ nick_name: Optional[str] = HTField('NickName')
33
+ last_name: str = HTField('LastName')
34
+ age: int = HTField('Age')
35
+ next_birthday: datetime = HTField('NextBirthday')
36
+ country_id: int = HTField('CountryID')
37
+ arrival_date: datetime = HTField('ArrivalDate')
38
+ expert_type: int = HTField('ExpertType')
39
+ hof_date: datetime = HTField('HofDate')
40
+ hof_age: int = HTField('HofAge')
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pychpp"
3
- version = "0.4.0b2"
3
+ version = "0.4.2"
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