pychpp 0.4.4__tar.gz → 0.4.6__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 (81) hide show
  1. {pychpp-0.4.4 → pychpp-0.4.6}/PKG-INFO +44 -39
  2. {pychpp-0.4.4 → pychpp-0.4.6}/README.md +43 -38
  3. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/chpp.py +96 -3
  4. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/ht_model.py +6 -4
  5. pychpp-0.4.6/pychpp/models/xml/live.py +108 -0
  6. pychpp-0.4.6/pychpp/models/xml/match_orders.py +178 -0
  7. pychpp-0.4.6/pychpp/models/xml/matches.py +82 -0
  8. pychpp-0.4.6/pychpp/models/xml/national_players.py +89 -0
  9. pychpp-0.4.6/pychpp/models/xml/national_team_matches.py +49 -0
  10. {pychpp-0.4.4 → pychpp-0.4.6}/pyproject.toml +1 -1
  11. {pychpp-0.4.4 → pychpp-0.4.6}/LICENSE +0 -0
  12. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/__init__.py +0 -0
  13. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/fixtures/__init__.py +0 -0
  14. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/fixtures/ht_datetime.py +0 -0
  15. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/fixtures/ht_error.py +0 -0
  16. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/__init__.py +0 -0
  17. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/__init__.py +0 -0
  18. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/__init__.py +0 -0
  19. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_arena.py +0 -0
  20. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_country.py +0 -0
  21. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_league.py +0 -0
  22. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_league_unit.py +0 -0
  23. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_match.py +0 -0
  24. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_player.py +0 -0
  25. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_region.py +0 -0
  26. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_team.py +0 -0
  27. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/base/ht_user.py +0 -0
  28. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_arena.py +0 -0
  29. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_challenge.py +0 -0
  30. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_league.py +0 -0
  31. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_league_unit.py +0 -0
  32. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_match.py +0 -0
  33. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_match_lineup.py +0 -0
  34. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_matches_archive.py +0 -0
  35. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_player.py +0 -0
  36. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_region.py +0 -0
  37. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_team.py +0 -0
  38. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_transfer_history.py +0 -0
  39. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_user.py +0 -0
  40. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_youth_player.py +0 -0
  41. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/custom/ht_youth_team.py +0 -0
  42. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/ht_field.py +0 -0
  43. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/ht_init_var.py +0 -0
  44. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/ht_version.py +0 -0
  45. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/ht_xml.py +0 -0
  46. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/__init__.py +0 -0
  47. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/achievements.py +0 -0
  48. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/alliance_details.py +0 -0
  49. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/alliances.py +0 -0
  50. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/arena_details.py +0 -0
  51. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/avatars.py +0 -0
  52. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/bookmarks.py +0 -0
  53. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/challenges.py +0 -0
  54. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/club.py +0 -0
  55. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/cup_matches.py +0 -0
  56. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/current_bids.py +0 -0
  57. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/economy.py +0 -0
  58. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/fans.py +0 -0
  59. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/hof_players.py +0 -0
  60. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/ladder_details.py +0 -0
  61. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/ladder_list.py +0 -0
  62. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/league_details.py +0 -0
  63. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/league_fixtures.py +0 -0
  64. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/league_levels.py +0 -0
  65. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/manager_compendium.py +0 -0
  66. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/match_details.py +0 -0
  67. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/match_lineup.py +0 -0
  68. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/matches_archive.py +0 -0
  69. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/national_team_details.py +0 -0
  70. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/national_teams.py +0 -0
  71. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/player_details.py +0 -0
  72. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/players.py +0 -0
  73. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/region_details.py +0 -0
  74. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/team_details.py +0 -0
  75. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/training.py +0 -0
  76. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/transfers_team.py +0 -0
  77. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/world_cup.py +0 -0
  78. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/world_details.py +0 -0
  79. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/youth_player_details.py +0 -0
  80. {pychpp-0.4.4 → pychpp-0.4.6}/pychpp/models/xml/youth_player_list.py +0 -0
  81. {pychpp-0.4.4 → pychpp-0.4.6}/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.4
3
+ Version: 0.4.6
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
@@ -165,47 +165,52 @@ Then, to use this new class:
165
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.
166
166
 
167
167
  ## List of supported CHPP XML files
168
- ![35/57](https://progress-bar.xyz/61/?title=35%20on%2057)
168
+ ![40/57](https://progress-bar.xyz/70/?title=40%20on%2057)
169
169
 
170
170
  The following table shows the CHPP XML files that are currently supported:
171
171
 
172
- | pyCHPP class | CHPP XML files |
173
- |:-----------------------:|:-------------------------:|
174
- | Achievements | `achievements.xml` |
175
- | Alliances | `alliances.xml` |
176
- | AllianceDetails | `alliancedetails.xml` |
177
- | Arena | `arenadetails.xml` |
178
- | Avatars | `avatars.xml` |
179
- | Bookmarks | `bookmarks.xml` |
180
- | Challenges | `challenges.xml` |
181
- | Club | `club.xml` |
182
- | CupMatches | `cupmatches.xml` |
183
- | CurrentBids | `currentbids.xml` |
184
- | Economy | `economy.xml` |
185
- | Fans | `fans.xml` |
186
- | HallOfFamePlayers | `hofplayers.xml` |
187
- | LadderDetails | `ladderdetails.xml` |
188
- | LadderList | `ladderlist.xml` |
189
- | LeagueDetails | `leaguedetails.xml` |
190
- | LeagueFixtures | `leaguefixtures.xml` |
191
- | LeagueLevels | `leaguelevels.xml` |
192
- | ManagerCompendium | `managercompendium.xml` |
193
- | MatchDetails | `matchdetails.xml` |
194
- | MatchLineup | `matchlineup.xml` |
195
- | MatchesArchive | `matchesarchive.xml` |
196
- | NationalTeamDetails | `nationalteamdetails.xml` |
197
- | NationalTeams | `nationalteams.xml` |
198
- | PlayerDetails | `playerdetails.xml` |
199
- | Players | `players.xml` |
200
- | RegionDetails | `regiondetails.xml` |
201
- | TeamDetails | `teamdetails.xml` |
202
- | Training | `training.xml` |
203
- | TransfersTeam | `transfersteam.xml` |
204
- | WorldCup | `worldcup.xml` |
205
- | WorldDetails | `worlddetails.xml` |
206
- | YouthPlayerDetails | `youthplayerdetails.xml` |
207
- | YouthPlayerList | `youthplayerlist.xml` |
208
- | YouthTeamDetails | `youthteamdetails.xml` |
172
+ | pyCHPP class | CHPP XML files |
173
+ |:-------------------:|:-------------------------:|
174
+ | Achievements | `achievements.xml` |
175
+ | Alliances | `alliances.xml` |
176
+ | AllianceDetails | `alliancedetails.xml` |
177
+ | Arena | `arenadetails.xml` |
178
+ | Avatars | `avatars.xml` |
179
+ | Bookmarks | `bookmarks.xml` |
180
+ | Challenges | `challenges.xml` |
181
+ | Club | `club.xml` |
182
+ | CupMatches | `cupmatches.xml` |
183
+ | CurrentBids | `currentbids.xml` |
184
+ | Economy | `economy.xml` |
185
+ | Fans | `fans.xml` |
186
+ | HallOfFamePlayers | `hofplayers.xml` |
187
+ | LadderDetails | `ladderdetails.xml` |
188
+ | LadderList | `ladderlist.xml` |
189
+ | LeagueDetails | `leaguedetails.xml` |
190
+ | LeagueFixtures | `leaguefixtures.xml` |
191
+ | LeagueLevels | `leaguelevels.xml` |
192
+ | Live | `live.xml` |
193
+ | ManagerCompendium | `managercompendium.xml` |
194
+ | MatchDetails | `matchdetails.xml` |
195
+ | MatchLineup | `matchlineup.xml` |
196
+ | MatchOrders | `matchorders.xml` |
197
+ | MatchesArchive | `matchesarchive.xml` |
198
+ | Matches | `matches.xml` |
199
+ | NationalTeamDetails | `nationalteamdetails.xml` |
200
+ | NationalTeamMatches | `nationalteammatches.xml` |
201
+ | NationalTeams | `nationalteams.xml` |
202
+ | NationalPlayers | `nationalplayers.xml` |
203
+ | PlayerDetails | `playerdetails.xml` |
204
+ | Players | `players.xml` |
205
+ | RegionDetails | `regiondetails.xml` |
206
+ | TeamDetails | `teamdetails.xml` |
207
+ | Training | `training.xml` |
208
+ | TransfersTeam | `transfersteam.xml` |
209
+ | WorldCup | `worldcup.xml` |
210
+ | WorldDetails | `worlddetails.xml` |
211
+ | YouthPlayerDetails | `youthplayerdetails.xml` |
212
+ | YouthPlayerList | `youthplayerlist.xml` |
213
+ | YouthTeamDetails | `youthteamdetails.xml` |
209
214
 
210
215
  ## License
211
216
  pyCHPP is licensed under the Apache License 2.0.
@@ -143,47 +143,52 @@ 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
- ![35/57](https://progress-bar.xyz/61/?title=35%20on%2057)
146
+ ![40/57](https://progress-bar.xyz/70/?title=40%20on%2057)
147
147
 
148
148
  The following table shows the CHPP XML files that are currently supported:
149
149
 
150
- | pyCHPP class | CHPP XML files |
151
- |:-----------------------:|:-------------------------:|
152
- | Achievements | `achievements.xml` |
153
- | Alliances | `alliances.xml` |
154
- | AllianceDetails | `alliancedetails.xml` |
155
- | Arena | `arenadetails.xml` |
156
- | Avatars | `avatars.xml` |
157
- | Bookmarks | `bookmarks.xml` |
158
- | Challenges | `challenges.xml` |
159
- | Club | `club.xml` |
160
- | CupMatches | `cupmatches.xml` |
161
- | CurrentBids | `currentbids.xml` |
162
- | Economy | `economy.xml` |
163
- | Fans | `fans.xml` |
164
- | HallOfFamePlayers | `hofplayers.xml` |
165
- | LadderDetails | `ladderdetails.xml` |
166
- | LadderList | `ladderlist.xml` |
167
- | LeagueDetails | `leaguedetails.xml` |
168
- | LeagueFixtures | `leaguefixtures.xml` |
169
- | LeagueLevels | `leaguelevels.xml` |
170
- | ManagerCompendium | `managercompendium.xml` |
171
- | MatchDetails | `matchdetails.xml` |
172
- | MatchLineup | `matchlineup.xml` |
173
- | MatchesArchive | `matchesarchive.xml` |
174
- | NationalTeamDetails | `nationalteamdetails.xml` |
175
- | NationalTeams | `nationalteams.xml` |
176
- | PlayerDetails | `playerdetails.xml` |
177
- | Players | `players.xml` |
178
- | RegionDetails | `regiondetails.xml` |
179
- | TeamDetails | `teamdetails.xml` |
180
- | Training | `training.xml` |
181
- | TransfersTeam | `transfersteam.xml` |
182
- | WorldCup | `worldcup.xml` |
183
- | WorldDetails | `worlddetails.xml` |
184
- | YouthPlayerDetails | `youthplayerdetails.xml` |
185
- | YouthPlayerList | `youthplayerlist.xml` |
186
- | YouthTeamDetails | `youthteamdetails.xml` |
150
+ | pyCHPP class | CHPP XML files |
151
+ |:-------------------:|:-------------------------:|
152
+ | Achievements | `achievements.xml` |
153
+ | Alliances | `alliances.xml` |
154
+ | AllianceDetails | `alliancedetails.xml` |
155
+ | Arena | `arenadetails.xml` |
156
+ | Avatars | `avatars.xml` |
157
+ | Bookmarks | `bookmarks.xml` |
158
+ | Challenges | `challenges.xml` |
159
+ | Club | `club.xml` |
160
+ | CupMatches | `cupmatches.xml` |
161
+ | CurrentBids | `currentbids.xml` |
162
+ | Economy | `economy.xml` |
163
+ | Fans | `fans.xml` |
164
+ | HallOfFamePlayers | `hofplayers.xml` |
165
+ | LadderDetails | `ladderdetails.xml` |
166
+ | LadderList | `ladderlist.xml` |
167
+ | LeagueDetails | `leaguedetails.xml` |
168
+ | LeagueFixtures | `leaguefixtures.xml` |
169
+ | LeagueLevels | `leaguelevels.xml` |
170
+ | Live | `live.xml` |
171
+ | ManagerCompendium | `managercompendium.xml` |
172
+ | MatchDetails | `matchdetails.xml` |
173
+ | MatchLineup | `matchlineup.xml` |
174
+ | MatchOrders | `matchorders.xml` |
175
+ | MatchesArchive | `matchesarchive.xml` |
176
+ | Matches | `matches.xml` |
177
+ | NationalTeamDetails | `nationalteamdetails.xml` |
178
+ | NationalTeamMatches | `nationalteammatches.xml` |
179
+ | NationalTeams | `nationalteams.xml` |
180
+ | NationalPlayers | `nationalplayers.xml` |
181
+ | PlayerDetails | `playerdetails.xml` |
182
+ | Players | `players.xml` |
183
+ | RegionDetails | `regiondetails.xml` |
184
+ | TeamDetails | `teamdetails.xml` |
185
+ | Training | `training.xml` |
186
+ | TransfersTeam | `transfersteam.xml` |
187
+ | WorldCup | `worldcup.xml` |
188
+ | WorldDetails | `worlddetails.xml` |
189
+ | YouthPlayerDetails | `youthplayerdetails.xml` |
190
+ | YouthPlayerList | `youthplayerlist.xml` |
191
+ | YouthTeamDetails | `youthteamdetails.xml` |
187
192
 
188
193
  ## License
189
194
  pyCHPP is licensed under the Apache License 2.0.
@@ -13,7 +13,8 @@ from pychpp.models.xml import (manager_compendium, team_details, achievements, a
13
13
  youth_player_details, youth_team_details, youth_player_list,
14
14
  matches_archive, match_details, cup_matches, alliances,
15
15
  alliance_details, avatars, bookmarks, club, current_bids, economy,
16
- fans, hof_players, ladder_details, ladder_list, league_levels)
16
+ fans, hof_players, ladder_details, ladder_list, league_levels, live,
17
+ matches, match_orders, national_team_matches, national_players)
17
18
  from pychpp.models.custom import (ht_team, ht_arena, ht_user, ht_region, ht_youth_team, ht_player,
18
19
  ht_league_unit, ht_youth_player, ht_league, ht_matches_archive,
19
20
  ht_match, ht_challenge, ht_match_lineup, ht_transfer_history)
@@ -272,7 +273,7 @@ class CHPPBase:
272
273
  )
273
274
 
274
275
  def _base_request(
275
- self, url, parse_data=True, **kwargs,
276
+ self, url, parse_data=True, method='GET', **kwargs,
276
277
  ) -> xml.etree.ElementTree:
277
278
  """
278
279
  Base method for sending a request via the CHPP API
@@ -282,7 +283,14 @@ class CHPPBase:
282
283
  :return: xml data fetched on Hattrick
283
284
  """
284
285
  session = self.open_session()
285
- query = session.get(url, params=kwargs)
286
+
287
+ if method == 'GET':
288
+ query = session.get(url, params=kwargs)
289
+ elif method == 'POST':
290
+ query = session.post(url, data=kwargs)
291
+ else:
292
+ raise ValueError(f"Unknown method '{method}'")
293
+
286
294
  query.encoding = "UTF-8"
287
295
  self.last_url = query.url
288
296
 
@@ -640,6 +648,20 @@ class CHPPXml(CHPPBase):
640
648
  chpp=self, league_id=league_id, **kwargs,
641
649
  )
642
650
 
651
+ def xml_live(
652
+ self, action_type: str = 'view', match_id: int = None,
653
+ source_system: str = 'hattrick', include_starting_lineup: bool = False,
654
+ use_live_events_and_texts: bool = False, last_shown_indexes: str = None,
655
+ **kwargs,
656
+ ) -> live.Live:
657
+
658
+ return live.Live(
659
+ chpp=self, action_type=action_type, match_id=match_id,
660
+ source_system=source_system, include_starting_lineup=include_starting_lineup,
661
+ use_live_events_and_texts=use_live_events_and_texts,
662
+ last_shown_indexes=last_shown_indexes, **kwargs,
663
+ )
664
+
643
665
  def xml_manager_compendium(
644
666
  self, user_id: int = None, **kwargs,
645
667
  ) -> manager_compendium.ManagerCompendium:
@@ -668,6 +690,47 @@ class CHPPXml(CHPPBase):
668
690
  source_system=source_system, **kwargs,
669
691
  )
670
692
 
693
+ def xml_match_orders(
694
+ self, match_id: int, action_type: str = 'view', team_id: int = None,
695
+ source_system: str = 'Hattrick', lineup: str = None, **kwargs,
696
+ ) -> Union[match_orders.MatchOrdersView,
697
+ match_orders.MatchOrdersSetMatchOrder,
698
+ match_orders.MatchOrdersPredictRatings,
699
+ ]:
700
+
701
+ if action_type == 'view':
702
+ return match_orders.MatchOrdersView(
703
+ chpp=self, action_type=action_type, match_id=match_id,
704
+ team_id=team_id, source_system=source_system, lineup=lineup,
705
+ **kwargs,
706
+ )
707
+
708
+ elif action_type == 'setmatchorder':
709
+ return match_orders.MatchOrdersSetMatchOrder(
710
+ chpp=self, action_type=action_type, match_id=match_id,
711
+ team_id=team_id, source_system=source_system, lineup=lineup,
712
+ **kwargs,
713
+ )
714
+
715
+ elif action_type == 'predictratings':
716
+ return match_orders.MatchOrdersPredictRatings(
717
+ chpp=self, action_type=action_type, match_id=match_id,
718
+ team_id=team_id, source_system=source_system, lineup=lineup,
719
+ **kwargs,
720
+ )
721
+
722
+ else:
723
+ raise ValueError("if set, 'action_type' must be equal to"
724
+ "'view', 'setmatchorder' or 'predictratings'")
725
+
726
+ def xml_matches(
727
+ self, team_id: int = None, is_youth: bool = None, **kwargs,
728
+ ) -> matches.Matches:
729
+
730
+ return matches.Matches(
731
+ chpp=self, team_id=team_id, is_youth=is_youth, **kwargs,
732
+ )
733
+
671
734
  def xml_matches_archive(
672
735
  self, team_id: int = None, is_youth: bool = None,
673
736
  first_match_date: datetime = None, last_match_date: datetime = None,
@@ -696,6 +759,36 @@ class CHPPXml(CHPPBase):
696
759
  chpp=self, team_id=team_id, **kwargs,
697
760
  )
698
761
 
762
+ def xml_national_team_matches(
763
+ self, league_office_type_id: int = None, **kwargs,
764
+ ) -> national_team_matches.NationalTeamMatches:
765
+
766
+ return national_team_matches.NationalTeamMatches(
767
+ chpp=self, league_office_type_id=league_office_type_id, **kwargs,
768
+ )
769
+
770
+ def xml_national_players(
771
+ self, team_id: int, action_type: str = 'view', match_type_category: int = None,
772
+ show_all: bool = None, **kwargs,
773
+ ) -> Union[national_players.NationalPlayersView,
774
+ national_players.NationalPlayersStats,
775
+ ]:
776
+
777
+ if action_type == 'view':
778
+ return national_players.NationalPlayersView(
779
+ chpp=self, action_type=action_type, team_id=team_id, **kwargs,
780
+ )
781
+
782
+ elif action_type == 'SupporterStats':
783
+ return national_players.NationalPlayersStats(
784
+ chpp=self, action_type=action_type, team_id=team_id,
785
+ match_type_category=match_type_category, show_all=show_all, **kwargs,
786
+ )
787
+
788
+ else:
789
+ raise ValueError("if set, 'action_type' must be equal to"
790
+ "'view', 'setmatchorder' or 'SupporterStats'")
791
+
699
792
  def xml_players(self, action_type: str = 'view', order_by: str = None,
700
793
  team_id: int = None, include_match_info: bool = None, **kwargs,
701
794
  ) -> Union[players.PlayersView,
@@ -1,6 +1,6 @@
1
1
  import pathlib
2
2
  from copy import copy
3
- from typing import Optional, Type, Dict, Any, List
3
+ from typing import Optional, Type, Dict, Any
4
4
  import xml.etree.ElementTree as ElementTree
5
5
  from datetime import datetime, date
6
6
  from typing import get_type_hints, get_origin, Union, get_args
@@ -43,7 +43,8 @@ class MetaHTModel(type):
43
43
 
44
44
  class HTModel(metaclass=MetaHTModel):
45
45
 
46
- SOURCE_FILE: List[str]
46
+ SOURCE_FILE: str
47
+ METHOD: str = 'GET'
47
48
  LAST_VERSION: str
48
49
  URL_PATH: Optional[str] = None
49
50
  XML_PREFIX: str = ''
@@ -144,12 +145,12 @@ class HTModel(metaclass=MetaHTModel):
144
145
 
145
146
  # if data is None, fetch data on Hattrick
146
147
  if self._data is None:
147
- self._fetch(version, **kwargs)
148
+ self._fetch(**kwargs)
148
149
 
149
150
  # Once data is obtained, transform HTField to actual values
150
151
  self._transform_fields()
151
152
 
152
- def _fetch(self, version, **kwargs):
153
+ def _fetch(self, **kwargs):
153
154
 
154
155
  # data is fetched using ht_init_vars attribute as query parameters
155
156
  for attr, ht_init_var in self._ht_init_vars.items():
@@ -179,6 +180,7 @@ class HTModel(metaclass=MetaHTModel):
179
180
 
180
181
  # self._data is filled with the file returned by the API call
181
182
  self._data = self._chpp.request(file=self.SOURCE_FILE,
183
+ method=self.METHOD,
182
184
  version=self.version.as_string,
183
185
  **self._requests_args,
184
186
  )
@@ -0,0 +1,108 @@
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 RequestLive(HTModel):
10
+ """
11
+ Live - Request arguments
12
+ """
13
+ SOURCE_FILE = 'live'
14
+ LAST_VERSION = '2.3'
15
+
16
+ _r_action_type: Optional[str] = HTInitVar('actionType', init_arg='action_type')
17
+ _r_match_id: Optional[int] = HTInitVar('matchID', init_arg='match_id')
18
+ _r_source_system: Optional[str] = HTInitVar('sourceSystem', init_arg='source_system')
19
+ _r_include_starting_lineup: Optional[bool] = HTInitVar('includeStartingLineup',
20
+ init_arg='include_starting_lineup')
21
+ _r_use_live_events_and_textx: Optional[bool] = HTInitVar('useLiveEventsAndTexts',
22
+ init_arg='use_live_events_and_texts')
23
+ _r_last_shown_indexes: Optional[str] = HTInitVar('lastShownIndexes',
24
+ init_arg='last_shown_indexes')
25
+
26
+
27
+ class Live(RequestLive):
28
+ """
29
+ Live
30
+ """
31
+ matches: Optional[List['MatchItem']] = HTField('MatchList', items='Match')
32
+
33
+
34
+ class MatchItem(HTModel):
35
+ """
36
+ Live -> Matches -> Match item
37
+ """
38
+ id: int = HTField('MatchID')
39
+ type: int = HTField('MatchType')
40
+ source_system: str = HTField('SourceSystem')
41
+ date: datetime = HTField('MatchDate')
42
+ home_team: 'HomeTeam' = HTField('HomeTeam')
43
+ away_team: 'AwayTeam' = HTField('AwayTeam')
44
+ substitutions: Optional[List['SubstitutionItem']] = HTField('Substitutions',
45
+ items='Substitution')
46
+ events: List['EventItem'] = HTField('EventList', items='Event')
47
+ home_goals: int = HTField('HomeGoals')
48
+ away_goals: int = HTField('AwayGoals')
49
+ last_shown_event_index: int = HTField('LastShownEventIndex')
50
+ next_event_minute: int = HTField('NextEventMinute')
51
+ next_event_match_part: int = HTField('NextEventMatchPart')
52
+
53
+
54
+ class HomeTeam(HTModel):
55
+ """
56
+ Live -> Matches -> Match item -> Home team
57
+ """
58
+ id: int = HTField('HomeTeamID')
59
+ name: str = HTField('HomeTeamName')
60
+ short_name: str = HTField('HomeTeamShortName')
61
+ starting_lineup: Optional[List['PlayerItem']] = HTField('StartingLineup', items='Player')
62
+
63
+
64
+ class AwayTeam(HTModel):
65
+ """
66
+ Live -> Matches -> Match item -> Away team
67
+ """
68
+ id: int = HTField('AwayTeamID')
69
+ name: str = HTField('AwayTeamName')
70
+ short_name: str = HTField('AwayTeamShortName')
71
+ starting_lineup: Optional[List['PlayerItem']] = HTField('StartingLineup', items='Player')
72
+
73
+
74
+ class PlayerItem(HTModel):
75
+ """
76
+ Live -> Matches -> Match item -> Home/Away team -> Starting Lineup -> Player item
77
+ """
78
+ id: int = HTField('PlayerID')
79
+ role_id: int = HTField('RoleID')
80
+ name: str = HTField('PlayerName')
81
+ behaviour: Optional[int] = HTField('Behaviour')
82
+
83
+
84
+ class SubstitutionItem(HTModel):
85
+ """
86
+ Live -> Matches -> Match item -> Substitutions -> Substitution item
87
+ """
88
+ team_id: int = HTField('TeamID')
89
+ subject_player_id: int = HTField('SubjectPlayerID')
90
+ object_player_id: int = HTField('ObjectPlayerID')
91
+ order_type: int = HTField('OrderType')
92
+ new_position_id: int = HTField('NewPositionId')
93
+ new_position_behaviour: int = HTField('NewPositionBehaviour')
94
+ match_minute: int = HTField('MatchMinute')
95
+
96
+
97
+ class EventItem(HTModel):
98
+ """
99
+ Live -> Matches -> Match item -> Event -> Event item
100
+ """
101
+ index: int = HTField('.', attrib='Index')
102
+ minute: int = HTField('Minute')
103
+ match_part: int = HTField('MatchPart')
104
+ key: str = HTField('EventKey')
105
+ text: str = HTField('EventText')
106
+ subject_team_id: int = HTField('SubjectTeamID')
107
+ subject_player_id: int = HTField('SubjectPlayerID')
108
+ object_player_id: int = HTField('ObjectPlayerID')
@@ -0,0 +1,178 @@
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 RequestMatchOrders(HTModel):
10
+ """
11
+ Match Orders - Request arguments
12
+ """
13
+ SOURCE_FILE = 'matchorders'
14
+ LAST_VERSION = '3.1'
15
+
16
+ _r_action_type: Optional[str] = HTInitVar('actionType', init_arg='action_type')
17
+ _r_match_id: int = HTInitVar('matchID', init_arg='match_id')
18
+ _r_team_id: Optional[int] = HTInitVar('teamid', init_arg='team_id')
19
+ _r_source_system: Optional[str] = HTInitVar('sourceSystem', init_arg='source_system')
20
+ _r_lineup: Optional[str] = HTInitVar('lineup', init_arg='lineup')
21
+
22
+
23
+ class CommonMatchOrders(RequestMatchOrders):
24
+ """
25
+ Match Orders
26
+ """
27
+ id: int = HTField('MatchID')
28
+ source_system: str = HTField('SourceSystem')
29
+
30
+
31
+ class MatchOrdersView(CommonMatchOrders):
32
+ """
33
+ Match Orders - View
34
+ """
35
+ match_data: Optional['MatchDataView'] = HTField('MatchData')
36
+
37
+
38
+ class MatchDataView(HTModel):
39
+ """
40
+ Match Orders - View -> Match Data
41
+ """
42
+ available: bool = HTField('.', attrib='Available')
43
+ home_team: 'Team' = HTField('HomeTeam', xml_prefix='Home')
44
+ away_team: 'Team' = HTField('AwayTeam', xml_prefix='Away')
45
+ arena: 'Arena' = HTField('Arena')
46
+ date: datetime = HTField('MatchDate')
47
+ type: int = HTField('MatchType')
48
+ attitude: Optional[int] = HTField('Attitude')
49
+ tactic_type: int = HTField('TacticType')
50
+ coach_modifier: Optional[int] = HTField('CoachModifier')
51
+ lineup: 'Lineup' = HTField('Lineup')
52
+ player_orders: List['PlayerOrderItem'] = HTField('PlayerOrders', items='PlayerOrder')
53
+
54
+
55
+ class Team(HTModel):
56
+ """
57
+ Match Orders - View -> Match Data -> Home/Away Team
58
+ """
59
+ id: int = HTField('TeamID')
60
+ name: str = HTField('TeamName')
61
+
62
+
63
+ class Arena(HTModel):
64
+ """
65
+ Match Orders - View -> Match Data -> Arena
66
+ """
67
+ id: int = HTField('ArenaID')
68
+ name: str = HTField('ArenaName')
69
+
70
+
71
+ class Lineup(HTModel):
72
+ """
73
+ Match Orders - View -> Match Data -> Lineup
74
+ """
75
+ positions: List['PositionPlayerItem'] = HTField('Positions', items='Player')
76
+ bench: List['BenchPlayerItem'] = HTField('Bench', items='Player')
77
+ kickers: List['KickerPlayerItem'] = HTField('Kickers', items='Player')
78
+ set_pieces: Optional['SetPieces'] = HTField('SetPieces')
79
+ captain: Optional['Captain'] = HTField('Captain')
80
+
81
+
82
+ class BasePlayer(HTModel):
83
+ """
84
+ Match Orders - View -> Match Data -> Lineup -> Base player
85
+ """
86
+ id: int = HTField('PlayerID')
87
+ first_name: str = HTField('FirstName')
88
+ nick_name: str = HTField('NickName')
89
+ last_name: str = HTField('LastName')
90
+
91
+
92
+ class PositionPlayerItem(BasePlayer):
93
+ """
94
+ Match Orders - View -> Match Data -> Lineup -> Positions -> Player item
95
+ """
96
+ role_id: int = HTField('RoleID')
97
+ behaviour: int = HTField('Behaviour')
98
+
99
+
100
+ class BenchPlayerItem(BasePlayer):
101
+ """
102
+ Match Orders - View -> Match Data -> Lineup -> Bench -> Player item
103
+ """
104
+ role_id: int = HTField('RoleID')
105
+
106
+
107
+ class KickerPlayerItem(HTModel):
108
+ """
109
+ Match Orders - View -> Match Data -> Lineup -> Kickers -> Player item
110
+ """
111
+ id: int = HTField('PlayerID')
112
+ role_id: int = HTField('RoleID')
113
+
114
+
115
+ class SetPieces(BasePlayer):
116
+ """
117
+ Match Orders - View -> Match Data -> Lineup -> Set Pieces
118
+ """
119
+
120
+
121
+ class Captain(BasePlayer):
122
+ """
123
+ Match Orders - View -> Match Data -> Lineup -> Captain
124
+ """
125
+
126
+
127
+ class PlayerOrderItem(HTModel):
128
+ """
129
+ Match Orders - View -> Match Data -> Player Orders -> Player order item
130
+ """
131
+ id: int = HTField('PlayerOrderID')
132
+ match_minute_criteria: int = HTField('MatchMinuteCriteria')
133
+ goal_diff_criteria: int = HTField('GoalDiffCriteria')
134
+ red_card_criteria: int = HTField('RedCardCriteria')
135
+ subject_player_id: int = HTField('SubjectPlayerID')
136
+ object_player_id: int = HTField('ObjectPlayerID')
137
+ order_type: int = HTField('OrderType')
138
+ new_position_id: int = HTField('NewPositionId')
139
+ new_position_behaviour: int = HTField('NewPositionBehaviour')
140
+ extra_integer: int = HTField('PlayerOrderExtraInteger')
141
+
142
+
143
+ class MatchOrdersSetMatchOrder(CommonMatchOrders):
144
+ """
145
+ Match Orders - Set match order
146
+ """
147
+ METHOD = 'POST'
148
+ match_data: Optional['MatchDataSetMatchOrder'] = HTField('MatchData')
149
+
150
+
151
+ class MatchDataSetMatchOrder(HTModel):
152
+ """
153
+ Match Orders - Set match order -> Match Data
154
+ """
155
+ orders_set: bool = HTField('.', attrib='OrdersSet')
156
+ reason: Optional[str] = HTField('Reason')
157
+
158
+
159
+ class MatchOrdersPredictRatings(CommonMatchOrders):
160
+ """
161
+ Match Orders - Predict Ratings
162
+ """
163
+ match_data: Optional['MatchDataPredictRatings'] = HTField('MatchData')
164
+
165
+
166
+ class MatchDataPredictRatings(HTModel):
167
+ """
168
+ Match Orders - Predict Ratings -> Match Data
169
+ """
170
+ tactic_type: int = HTField('TacticType')
171
+ tactic_skill: int = HTField('TacticSkill')
172
+ rating_midfield: int = HTField('RatingMidfield')
173
+ rating_right_def: int = HTField('RatingRightDef')
174
+ rating_mid_def: int = HTField('RatingMidDef')
175
+ rating_left_def: int = HTField('RatingLeftDef')
176
+ rating_right_att: int = HTField('RatingRightAtt')
177
+ rating_mid_att: int = HTField('RatingMidAtt')
178
+ rating_left_att: int = HTField('RatingLeftAtt')
@@ -0,0 +1,82 @@
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 RequestMatches(HTModel):
10
+ """
11
+ Matches - Request arguments
12
+ """
13
+ SOURCE_FILE = 'matches'
14
+ LAST_VERSION = '2.9'
15
+
16
+ _r_team_id: Optional[int] = HTInitVar('teamID', init_arg='team_id')
17
+ _r_is_youth: Optional[bool] = HTInitVar('isYouth', init_arg='is_youth')
18
+ _r_last_match_date: Optional[datetime] = HTInitVar('LastMatchDate', init_arg='last_match_date')
19
+
20
+
21
+ class Matches(RequestMatches):
22
+ """
23
+ Matches
24
+ """
25
+ team: 'Team' = HTField('Team')
26
+
27
+
28
+ class Team(HTModel):
29
+ """
30
+ Matches -> Team
31
+ """
32
+ id: int = HTField('TeamID')
33
+ name: str = HTField('TeamName')
34
+ short_name: str = HTField('ShortTeamName')
35
+ league: 'League' = HTField('League')
36
+ league_level_unit: 'LeagueLevelUnit' = HTField('LeagueLevelUnit')
37
+ matches: Optional[List['MatchItem']] = HTField('MatchList', items='Match')
38
+
39
+
40
+ class League(HTModel):
41
+ """
42
+ Matches -> Team -> League
43
+ """
44
+ id: int = HTField('LeagueID')
45
+ name: str = HTField('LeagueName')
46
+
47
+
48
+ class LeagueLevelUnit(HTModel):
49
+ """
50
+ Matches -> Team -> League -> League Level Unit
51
+ """
52
+ id: int = HTField('LeagueLevelUnitID')
53
+ name: str = HTField('LeagueLevelUnitName')
54
+ level: int = HTField('LeagueLevel')
55
+
56
+
57
+ class MatchItem(HTModel):
58
+ """
59
+ Matches -> Team -> Matches -> Match item
60
+ """
61
+ id: int = HTField('MatchID')
62
+ home_team: 'MatchItemTeam' = HTField('HomeTeam', xml_prefix='Home')
63
+ away_team: 'MatchItemTeam' = HTField('AwayTeam', xml_prefix='Away')
64
+ date: datetime = HTField('MatchDate')
65
+ source_system: str = HTField('SourceSystem')
66
+ type: int = HTField('MatchType')
67
+ context_id: int = HTField('MatchContextId')
68
+ cup_level: int = HTField('CupLevel')
69
+ cup_level_index: int = HTField('CupLevelIndex')
70
+ home_goals: Optional[int] = HTField('HomeGoals')
71
+ away_goals: Optional[int] = HTField('AwayGoals')
72
+ status: str = HTField('Status')
73
+ orders_given: Optional[bool] = HTField('OrdersGiven')
74
+
75
+
76
+ class MatchItemTeam(HTModel):
77
+ """
78
+ Matches -> Team -> Matches -> Match item -> Home/Away team
79
+ """
80
+ id: int = HTField('TeamID')
81
+ name: str = HTField('TeamName')
82
+ short_name: str = HTField('TeamNameShortName')
@@ -0,0 +1,89 @@
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 RequestNationalPlayers(HTModel):
9
+ """
10
+ National Players - Request arguments
11
+ """
12
+ SOURCE_FILE = 'nationalplayers'
13
+ LAST_VERSION = '1.5'
14
+
15
+ _r_action_type: Optional[str] = HTInitVar('actionType', init_arg='action_type')
16
+ _r_team_id: int = HTInitVar('teamID', init_arg='team_id')
17
+ _r_match_type_category: Optional[str] = HTInitVar('MatchTypeCategory',
18
+ init_arg='match_type_category')
19
+ _r_show_all: Optional[bool] = HTInitVar('ShowAll', init_arg='show_all')
20
+
21
+
22
+ class NationalPlayersView(RequestNationalPlayers):
23
+ """
24
+ National Players - View
25
+ """
26
+ user_supporter_tier: str = HTField('UserSupporterTier')
27
+ action_type: str = HTField('ActionType')
28
+ team_id: int = HTField('TeamID')
29
+ team_name: str = HTField('TeamName')
30
+ players: List['ViewPlayerItem'] = HTField('Players', items='Player')
31
+
32
+
33
+ class ViewPlayerItem(HTModel):
34
+ """
35
+ National Players - View -> Players -> Player item
36
+ """
37
+ id: int = HTField('PlayerID')
38
+ name: str = HTField('PlayerName')
39
+ cards: int = HTField('Cards')
40
+ specialty: int = HTField('Specialty')
41
+ avatar: 'Avatar' = HTField('Avatar')
42
+
43
+
44
+ class Avatar(HTModel):
45
+ """
46
+ National Players - View -> Players -> Player item -> Avatar
47
+ """
48
+ background_image: str = HTField('BackgroundImage')
49
+ layer: 'Layer' = HTField('Layer')
50
+
51
+
52
+ class Layer(HTModel):
53
+ """
54
+ National Players - View -> Players -> Player item -> Avatar -> Layer
55
+ """
56
+ x: int = HTField('.', attrib='x')
57
+ y: int = HTField('.', attrib='y')
58
+ image: str = HTField('Image')
59
+
60
+
61
+ class NationalPlayersStats(RequestNationalPlayers):
62
+ """
63
+ National Players - Supporter Stats
64
+ """
65
+ user_is_supporter: bool = HTField('UserIsSupporter')
66
+ user_has_clubhouse: bool = HTField('UserHasClubhouse')
67
+ action_type: str = HTField('ActionType')
68
+ team_id: int = HTField('TeamID')
69
+ team_name: str = HTField('TeamName')
70
+ stats: 'Stats' = HTField('Stats')
71
+
72
+
73
+ class Stats(HTModel):
74
+ """
75
+ National Players - Supporter Stats -> Stats
76
+ """
77
+ match_type_category: str = HTField('MatchTypeCategory')
78
+ show_all: bool = HTField('ShowAll')
79
+ more_records_available: bool = HTField('MoreRecordsAvailable')
80
+ players: List['PlayerItemStats'] = HTField('Players', items='Player')
81
+
82
+
83
+ class PlayerItemStats(HTModel):
84
+ """
85
+ National Players - Supporter Stats -> Stats -> Players -> Player item
86
+ """
87
+ id: int = HTField('PlayerID')
88
+ name: str = HTField('PlayerName')
89
+ nr_of_matches: int = HTField('NrOfMatches')
@@ -0,0 +1,49 @@
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 RequestNationalTeamMatches(HTModel):
10
+ """
11
+ National Team Matches - Request arguments
12
+ """
13
+ SOURCE_FILE = 'nationalteammatches'
14
+ LAST_VERSION = '1.4'
15
+
16
+ _r_league_office_type_id: Optional[int] = HTInitVar('LeagueOfficeTypeID',
17
+ init_arg='league_office_type_id')
18
+
19
+
20
+ class NationalTeamMatches(RequestNationalTeamMatches):
21
+ """
22
+ National Team Matches
23
+ """
24
+ user_supporter_tier: str = HTField('UserSupporterTier')
25
+ league_office_type_id: int = HTField('LeagueOfficeTypeID')
26
+ matches: List['MatchItem'] = HTField('Matches', items='Match')
27
+
28
+
29
+ class MatchItem(HTModel):
30
+ """
31
+ National Team Matches -> Matches -> Match item
32
+ """
33
+ id: int = HTField('MatchID')
34
+ date: datetime = HTField('MatchDate')
35
+ type: int = HTField('MatchType')
36
+ context_id: Optional[int] = HTField('MatchContextId')
37
+ home_team_id: int = HTField('HomeTeamId')
38
+ home_team_name: str = HTField('HomeTeamName')
39
+ away_team_id: int = HTField('AwayTeamId')
40
+ away_team_name: str = HTField('AwayTeamName')
41
+ match_result: Optional['MatchResult'] = HTField('MatchResult')
42
+
43
+
44
+ class MatchResult(HTModel):
45
+ """
46
+ National Team Matches -> Matches -> Match item -> Match result
47
+ """
48
+ home_goals: Optional[int] = HTField('HomeGoals')
49
+ away_goals: Optional[int] = HTField('AwayGoals')
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pychpp"
3
- version = "0.4.4"
3
+ version = "0.4.6"
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>"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes