pychpp 0.5.1__tar.gz → 0.5.3__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 (98) hide show
  1. {pychpp-0.5.1 → pychpp-0.5.3}/PKG-INFO +6 -7
  2. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/chpp.py +27 -6
  3. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/match_details.py +33 -33
  4. {pychpp-0.5.1 → pychpp-0.5.3}/pyproject.toml +5 -5
  5. {pychpp-0.5.1 → pychpp-0.5.3}/LICENSE +0 -0
  6. {pychpp-0.5.1 → pychpp-0.5.3}/README.md +0 -0
  7. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/__init__.py +0 -0
  8. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/fixtures/__init__.py +0 -0
  9. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/fixtures/ht_datetime.py +0 -0
  10. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/fixtures/ht_error.py +0 -0
  11. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/__init__.py +0 -0
  12. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/__init__.py +0 -0
  13. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/__init__.py +0 -0
  14. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_arena.py +0 -0
  15. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_country.py +0 -0
  16. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_league.py +0 -0
  17. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_league_unit.py +0 -0
  18. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_match.py +0 -0
  19. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_player.py +0 -0
  20. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_region.py +0 -0
  21. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_team.py +0 -0
  22. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/base/ht_user.py +0 -0
  23. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_arena.py +0 -0
  24. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_challenge.py +0 -0
  25. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_league.py +0 -0
  26. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_league_unit.py +0 -0
  27. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_match.py +0 -0
  28. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_match_lineup.py +0 -0
  29. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_matches_archive.py +0 -0
  30. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_player.py +0 -0
  31. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_region.py +0 -0
  32. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_team.py +0 -0
  33. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_transfer_history.py +0 -0
  34. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_user.py +0 -0
  35. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_youth_player.py +0 -0
  36. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/custom/ht_youth_team.py +0 -0
  37. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/ht_field.py +0 -0
  38. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/ht_init_var.py +0 -0
  39. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/ht_model.py +0 -0
  40. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/ht_version.py +0 -0
  41. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/ht_xml.py +0 -0
  42. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/__init__.py +0 -0
  43. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/achievements.py +0 -0
  44. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/alliance_details.py +0 -0
  45. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/alliances.py +0 -0
  46. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/arena_details.py +0 -0
  47. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/avatars.py +0 -0
  48. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/bookmarks.py +0 -0
  49. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/challenges.py +0 -0
  50. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/club.py +0 -0
  51. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/cup_matches.py +0 -0
  52. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/current_bids.py +0 -0
  53. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/economy.py +0 -0
  54. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/fans.py +0 -0
  55. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/hof_players.py +0 -0
  56. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/ladder_details.py +0 -0
  57. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/ladder_list.py +0 -0
  58. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/league_details.py +0 -0
  59. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/league_fixtures.py +0 -0
  60. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/league_levels.py +0 -0
  61. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/live.py +0 -0
  62. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/manager_compendium.py +0 -0
  63. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/match_lineup.py +0 -0
  64. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/match_orders.py +0 -0
  65. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/matches.py +0 -0
  66. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/matches_archive.py +0 -0
  67. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/national_players.py +0 -0
  68. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/national_team_details.py +0 -0
  69. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/national_team_matches.py +0 -0
  70. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/national_teams.py +0 -0
  71. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/player_details.py +0 -0
  72. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/player_events.py +0 -0
  73. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/players.py +0 -0
  74. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/region_details.py +0 -0
  75. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/search.py +0 -0
  76. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/staff_avatars.py +0 -0
  77. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/staff_list.py +0 -0
  78. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/supporters.py +0 -0
  79. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/team_details.py +0 -0
  80. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/tournament_details.py +0 -0
  81. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/tournament_fixtures.py +0 -0
  82. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/tournament_league_tables.py +0 -0
  83. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/tournament_list.py +0 -0
  84. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/training.py +0 -0
  85. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/training_events.py +0 -0
  86. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/transfer_search.py +0 -0
  87. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/transfers_player.py +0 -0
  88. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/transfers_team.py +0 -0
  89. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/translations.py +0 -0
  90. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/world_cup.py +0 -0
  91. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/world_details.py +0 -0
  92. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/world_languages.py +0 -0
  93. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/youth_avatars.py +0 -0
  94. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/youth_league_details.py +0 -0
  95. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/youth_league_fixtures.py +0 -0
  96. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/youth_player_details.py +0 -0
  97. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/youth_player_list.py +0 -0
  98. {pychpp-0.5.1 → pychpp-0.5.3}/pychpp/models/xml/youth_team_details.py +0 -0
@@ -1,23 +1,22 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: pychpp
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: framework created to use the API provided by the online game Hattrick
5
- Home-page: https://framagit.org/Pierre86/pychpp
6
5
  License: Apache-2.0
7
6
  Author: Pierre Gobin
8
7
  Author-email: p.dev@gobin.cc
9
- Requires-Python: >=3.8,<4.0
8
+ Requires-Python: >=3.9,<4.0
10
9
  Classifier: License :: OSI Approved :: Apache Software License
11
10
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
11
  Classifier: Programming Language :: Python :: 3.9
14
12
  Classifier: Programming Language :: Python :: 3.10
15
13
  Classifier: Programming Language :: Python :: 3.11
16
14
  Classifier: Programming Language :: Python :: 3.12
17
15
  Classifier: Programming Language :: Python :: 3.13
18
- Requires-Dist: Werkzeug (>=2.2.2,<3.0.0)
19
- Requires-Dist: pytz (>=2024.2,<2025.0)
16
+ Requires-Dist: Werkzeug (>=3.1.3,<4.0.0)
17
+ Requires-Dist: pytz (>=2025.1,<2026.0)
20
18
  Requires-Dist: requests-oauthlib (>=2.0.0,<3.0.0)
19
+ Project-URL: Homepage, https://framagit.org/Pierre86/pychpp
21
20
  Description-Content-Type: text/markdown
22
21
 
23
22
  # pyCHPP
@@ -1,9 +1,12 @@
1
1
  from datetime import datetime
2
+ from http.client import RemoteDisconnected
2
3
  from typing import Union, Optional
3
4
 
4
5
  import xml.etree.ElementTree
5
6
 
7
+ from requests.adapters import HTTPAdapter
6
8
  from requests_oauthlib import OAuth1Session
9
+ from urllib3 import Retry
7
10
 
8
11
  from pychpp.models.xml import (manager_compendium, team_details, achievements, arena_details,
9
12
  challenges, region_details, league_details, league_fixtures,
@@ -262,6 +265,15 @@ class CHPPBase:
262
265
  resource_owner_secret=self.access_token_secret,
263
266
  )
264
267
 
268
+ # retry strategy
269
+ retry_strategy = Retry(
270
+ total=5,
271
+ redirect=5,
272
+ backoff_factor=0.5,
273
+ )
274
+
275
+ self.session.mount("https://", HTTPAdapter(max_retries=retry_strategy))
276
+
265
277
  def _base_request(
266
278
  self, url, parse_data=True, method='GET', **kwargs,
267
279
  ) -> xml.etree.ElementTree:
@@ -272,15 +284,24 @@ class CHPPBase:
272
284
  :param parse_data: parse or not returned data as xml
273
285
  :return: xml data fetched on Hattrick
274
286
  """
287
+
288
+ def proceed_request():
289
+ if method == 'GET':
290
+ return self.session.get(url, params=kwargs)
291
+ elif method == 'POST':
292
+ return self.session.post(url, data=kwargs)
293
+ else:
294
+ raise ValueError(f"Unknown method '{method}'")
295
+
275
296
  if self.session is None:
276
297
  self.open_session()
277
298
 
278
- if method == 'GET':
279
- query = self.session.get(url, params=kwargs)
280
- elif method == 'POST':
281
- query = self.session.post(url, data=kwargs)
282
- else:
283
- raise ValueError(f"Unknown method '{method}'")
299
+ try:
300
+ query = proceed_request()
301
+
302
+ except RemoteDisconnected:
303
+ self.open_session()
304
+ query = proceed_request()
284
305
 
285
306
  query.encoding = "UTF-8"
286
307
  self.last_url = query.url
@@ -39,15 +39,15 @@ class Match(HTModel):
39
39
  cup_level: int = HTField('CupLevel')
40
40
  cup_level_index: int = HTField('CupLevelIndex')
41
41
  date: datetime = HTField('MatchDate')
42
- finished_date: datetime = HTField('FinishedDate')
43
- added_minutes: int = HTField('AddedMinutes')
42
+ finished_date: Optional[datetime] = HTField('FinishedDate')
43
+ added_minutes: Optional[int] = HTField('AddedMinutes')
44
44
  home_team: 'MatchHomeTeam' = HTField('HomeTeam')
45
45
  away_team: 'MatchAwayTeam' = HTField('AwayTeam')
46
46
  arena: 'MatchArena' = HTField('Arena')
47
47
  officials: 'MatchOfficials' = HTField('MatchOfficials')
48
- goals: List['MatchGoalItem'] = HTField('Scorers', items='Goal')
49
- bookings: List['MatchBookingItem'] = HTField('Bookings', items='Booking')
50
- injuries: List['MatchInjuryItem'] = HTField('Injuries', items='Injury')
48
+ goals: Optional[List['MatchGoalItem']] = HTField('Scorers', items='Goal')
49
+ bookings: Optional[List['MatchBookingItem']] = HTField('Bookings', items='Booking')
50
+ injuries: Optional[List['MatchInjuryItem']] = HTField('Injuries', items='Injury')
51
51
  possession: 'MatchPossession' = HTField('.')
52
52
  events: Optional[List['MatchEventItem']] = HTField('EventList', items='Event')
53
53
 
@@ -56,10 +56,10 @@ class BaseMatchTeam(HTModel):
56
56
  """
57
57
  Match Details -> Match -> Base Home/Away team
58
58
  """
59
- dress_uri: str = HTField('DressURI')
60
- formation: str = HTField('Formation')
61
- tactic_type: int = HTField('TacticType')
62
- tactic_skill: int = HTField('TacticSkill')
59
+ dress_uri: Optional[str] = HTField('DressURI')
60
+ formation: Optional[str] = HTField('Formation')
61
+ tactic_type: Optional[int] = HTField('TacticType')
62
+ tactic_skill: Optional[int] = HTField('TacticSkill')
63
63
  ratings: 'MatchTeamRatings' = HTField('.')
64
64
  team_attitude: Optional[int] = HTField('TeamAttitude')
65
65
  chances: 'MatchTeamChances' = HTField('.')
@@ -71,7 +71,7 @@ class MatchHomeTeam(BaseMatchTeam):
71
71
  """
72
72
  id: int = HTField('HomeTeamID')
73
73
  name: str = HTField('HomeTeamName')
74
- goals: int = HTField('HomeGoals')
74
+ goals: Optional[int] = HTField('HomeGoals')
75
75
 
76
76
 
77
77
  class MatchAwayTeam(BaseMatchTeam):
@@ -80,20 +80,20 @@ class MatchAwayTeam(BaseMatchTeam):
80
80
  """
81
81
  id: int = HTField('AwayTeamID')
82
82
  name: str = HTField('AwayTeamName')
83
- goals: int = HTField('AwayGoals')
83
+ goals: Optional[int] = HTField('AwayGoals')
84
84
 
85
85
 
86
86
  class MatchTeamRatings(HTModel):
87
87
  """
88
88
  Match Details -> Match -> Home/Away team -> Ratings
89
89
  """
90
- midfield: int = HTField('RatingMidfield')
91
- right_defense: int = HTField('RatingRightDef')
92
- mid_defense: int = HTField('RatingMidDef')
93
- left_defense: int = HTField('RatingLeftDef')
94
- right_attack: int = HTField('RatingRightDef')
95
- mid_attack: int = HTField('RatingMidDef')
96
- left_attack: int = HTField('RatingLeftDef')
90
+ midfield: Optional[int] = HTField('RatingMidfield')
91
+ right_defense: Optional[int] = HTField('RatingRightDef')
92
+ mid_defense: Optional[int] = HTField('RatingMidDef')
93
+ left_defense: Optional[int] = HTField('RatingLeftDef')
94
+ right_attack: Optional[int] = HTField('RatingRightAtt')
95
+ mid_attack: Optional[int] = HTField('RatingMidAtt')
96
+ left_attack: Optional[int] = HTField('RatingLeftAtt')
97
97
  indirect_set_pieces_defense: Optional[int] = HTField('RatingIndirectSetPiecesDef')
98
98
  indirect_set_pieces_attack: Optional[int] = HTField('RatingIndirectSetPiecesAtt')
99
99
 
@@ -102,11 +102,11 @@ class MatchTeamChances(HTModel):
102
102
  """
103
103
  Match Details -> Match -> Home/Away team -> Chances
104
104
  """
105
- left: int = HTField('NrOfChancesLeft')
106
- center: int = HTField('NrOfChancesCenter')
107
- right: int = HTField('NrOfChancesRight')
108
- special_events: int = HTField('NrOfChancesSpecialEvents')
109
- other: int = HTField('NrOfChancesOther')
105
+ left: Optional[int] = HTField('NrOfChancesLeft')
106
+ center: Optional[int] = HTField('NrOfChancesCenter')
107
+ right: Optional[int] = HTField('NrOfChancesRight')
108
+ special_events: Optional[int] = HTField('NrOfChancesSpecialEvents')
109
+ other: Optional[int] = HTField('NrOfChancesOther')
110
110
 
111
111
 
112
112
  class MatchArena(HTModel):
@@ -115,7 +115,7 @@ class MatchArena(HTModel):
115
115
  """
116
116
  id: int = HTField('ArenaID')
117
117
  name: str = HTField('ArenaName')
118
- weather_id: int = HTField('WeatherID')
118
+ weather_id: Optional[int] = HTField('WeatherID')
119
119
  sold: 'MatchArenaSold' = HTField('.')
120
120
 
121
121
 
@@ -123,11 +123,11 @@ class MatchArenaSold(HTModel):
123
123
  """
124
124
  Match Details -> Match -> Arena -> Sold
125
125
  """
126
- total: int = HTField('SoldTotal')
127
- terraces: int = HTField('SoldTerraces')
128
- basic: int = HTField('SoldBasic')
129
- roof: int = HTField('SoldRoof')
130
- vip: int = HTField('SoldVIP')
126
+ total: Optional[int] = HTField('SoldTotal')
127
+ terraces: Optional[int] = HTField('SoldTerraces')
128
+ basic: Optional[int] = HTField('SoldBasic')
129
+ roof: Optional[int] = HTField('SoldRoof')
130
+ vip: Optional[int] = HTField('SoldVIP')
131
131
 
132
132
 
133
133
  class MatchOfficials(HTModel):
@@ -206,10 +206,10 @@ class MatchPossession(HTModel):
206
206
  """
207
207
  Match Details -> Match -> Possession
208
208
  """
209
- first_half_home: int = HTField('PossessionFirstHalfHome')
210
- first_half_away: int = HTField('PossessionFirstHalfAway')
211
- second_half_home: int = HTField('PossessionSecondHalfHome')
212
- second_half_away: int = HTField('PossessionSecondHalfAway')
209
+ first_half_home: Optional[int] = HTField('PossessionFirstHalfHome')
210
+ first_half_away: Optional[int] = HTField('PossessionFirstHalfAway')
211
+ second_half_home: Optional[int] = HTField('PossessionSecondHalfHome')
212
+ second_half_away: Optional[int] = HTField('PossessionSecondHalfAway')
213
213
 
214
214
 
215
215
  class MatchEventItem(HTModel):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pychpp"
3
- version = "0.5.1"
3
+ version = "0.5.3"
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>"]
@@ -9,15 +9,15 @@ homepage = "https://framagit.org/Pierre86/pychpp"
9
9
 
10
10
 
11
11
  [tool.poetry.dependencies]
12
- python = "^3.8"
13
- pytz = "^2024.2"
14
- Werkzeug = "^2.2.2"
12
+ python = "^3.9"
13
+ pytz = "^2025.1"
14
+ Werkzeug = "^3.1.3"
15
15
  requests-oauthlib = "^2.0.0"
16
16
 
17
17
  [tool.poetry.group.dev.dependencies]
18
18
  pytest = "^8.3.3"
19
19
  pytest-dotenv = "^0.5.2"
20
- flake8 = "^5.0.4"
20
+ flake8 = "^7.1.2"
21
21
 
22
22
  [build-system]
23
23
  requires = ["poetry>=0.12"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes