pychpp 0.5.2__tar.gz → 0.5.4__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.
- {pychpp-0.5.2 → pychpp-0.5.4}/PKG-INFO +1 -1
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/chpp.py +27 -6
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/match_details.py +4 -4
- {pychpp-0.5.2 → pychpp-0.5.4}/pyproject.toml +1 -1
- {pychpp-0.5.2 → pychpp-0.5.4}/LICENSE +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/README.md +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/__init__.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/fixtures/__init__.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/fixtures/ht_datetime.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/fixtures/ht_error.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/__init__.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/__init__.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/__init__.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_arena.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_country.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_league.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_league_unit.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_match.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_player.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_region.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_team.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/base/ht_user.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_arena.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_challenge.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_league.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_league_unit.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_match.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_match_lineup.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_matches_archive.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_player.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_region.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_team.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_transfer_history.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_user.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_youth_player.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/custom/ht_youth_team.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/ht_field.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/ht_init_var.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/ht_model.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/ht_version.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/ht_xml.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/__init__.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/achievements.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/alliance_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/alliances.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/arena_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/avatars.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/bookmarks.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/challenges.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/club.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/cup_matches.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/current_bids.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/economy.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/fans.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/hof_players.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/ladder_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/ladder_list.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/league_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/league_fixtures.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/league_levels.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/live.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/manager_compendium.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/match_lineup.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/match_orders.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/matches.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/matches_archive.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/national_players.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/national_team_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/national_team_matches.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/national_teams.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/player_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/player_events.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/players.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/region_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/search.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/staff_avatars.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/staff_list.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/supporters.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/team_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/tournament_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/tournament_fixtures.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/tournament_league_tables.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/tournament_list.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/training.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/training_events.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/transfer_search.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/transfers_player.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/transfers_team.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/translations.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/world_cup.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/world_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/world_languages.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/youth_avatars.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/youth_league_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/youth_league_fixtures.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/youth_player_details.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/youth_player_list.py +0 -0
- {pychpp-0.5.2 → pychpp-0.5.4}/pychpp/models/xml/youth_team_details.py +0 -0
|
@@ -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
|
-
|
|
279
|
-
query =
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
|
@@ -44,7 +44,7 @@ class Match(HTModel):
|
|
|
44
44
|
home_team: 'MatchHomeTeam' = HTField('HomeTeam')
|
|
45
45
|
away_team: 'MatchAwayTeam' = HTField('AwayTeam')
|
|
46
46
|
arena: 'MatchArena' = HTField('Arena')
|
|
47
|
-
officials: 'MatchOfficials' = HTField('MatchOfficials')
|
|
47
|
+
officials: Optional['MatchOfficials'] = HTField('MatchOfficials')
|
|
48
48
|
goals: Optional[List['MatchGoalItem']] = HTField('Scorers', items='Goal')
|
|
49
49
|
bookings: Optional[List['MatchBookingItem']] = HTField('Bookings', items='Booking')
|
|
50
50
|
injuries: Optional[List['MatchInjuryItem']] = HTField('Injuries', items='Injury')
|
|
@@ -91,9 +91,9 @@ class MatchTeamRatings(HTModel):
|
|
|
91
91
|
right_defense: Optional[int] = HTField('RatingRightDef')
|
|
92
92
|
mid_defense: Optional[int] = HTField('RatingMidDef')
|
|
93
93
|
left_defense: Optional[int] = HTField('RatingLeftDef')
|
|
94
|
-
right_attack: Optional[int] = HTField('
|
|
95
|
-
mid_attack: Optional[int] = HTField('
|
|
96
|
-
left_attack: Optional[int] = HTField('
|
|
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
|
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|