Skip to content

Fixtures

pychpp.fixtures.ht_datetime

Datetime helpers used in pychpp.

HTDatetime

HTDatetime(
    season=None,
    week=None,
    weekday=None,
    year=None,
    month=None,
    day=None,
    hour=0,
    minute=0,
    second=0,
    datetime=None,
    league=None,
    timezone=None,
)

Hattrick datetime.

Convert between a calendar datetime and the Hattrick calendar (season, week, weekday).

Initialize a HTDatetime instance.

Parameters:

Name Type Description Default
season Optional[int]

Hattrick season (from season 1).

None
week Optional[int]

Hattrick week in the season (from 1 to 16).

None
weekday Optional[int]

Weekday in the Hattrick week (from 1 to 7).

None
year Optional[int]

Calendar year (from 1997).

None
month Optional[int]

Calendar month (from 1 to 12).

None
day Optional[int]

Calendar day in the month (from 1 to 31).

None
hour

Hour in the day (from 0 to 23).

0
minute

Minute in the hour (from 0 to 59).

0
second

Second in the minute (from 0 to 59).

0
datetime Optional[datetime]

Date and time (from 1997-09-22 00:00).

None
league Optional[int | str]

League for which the HTDatetime is given (ID or name).

None
timezone Optional[str]

Timezone used to localize the HTDatetime.

None

datetime property writable

datetime

Underlying datetime object.

day property writable

day

Day of the datetime.

hour property writable

hour

Hour of the datetime.

league property writable

league

League name, used to compute the season.

minute property writable

minute

Minute of the datetime.

month property writable

month

Month of the datetime.

season property writable

season

Season number.

second property writable

second

Second of the datetime.

timezone property writable

timezone

Timezone of the datetime.

week property writable

week

Week number in the season.

weekday property writable

weekday

Day of the week.

year property writable

year

Year of the datetime.

from_calendar classmethod

from_calendar(
    year, month, day, hour=0, minute=0, second=0, **kwargs
)

Build a HTDatetime from a calendar date (year, month, day).

from_datetime classmethod

from_datetime(datetime, **kwargs)

Build a HTDatetime from a datetime object.

from_ht_calendar classmethod

from_ht_calendar(
    season,
    week,
    weekday,
    hour=0,
    minute=0,
    second=0,
    **kwargs,
)

Build a HTDatetime from a Hattrick calendar date (season, week, weekday).

pychpp.fixtures.ht_error

Exceptions raised when the CHPP API returns an error.

HTAccessDeniedError

Bases: HTError

Raised when Hattrick denies access to a parameter or file (error code 1).

HTAgeError

Bases: HTError

Raised when age can't be well-defined.

HTArenaNotAvailableError

Bases: HTChallengeError

Raised when arena is busy.

HTChallengeError

Bases: HTError

Raised when error occurs on Hattrick with challenges.

HTChallengesNotOpenedError

Bases: HTChallengeError

Raised when challenges can't be organized yet (too soon).

HTError

Bases: Exception

Base Hattrick error.

HTNotOwnedTeamError

Bases: HTError

Raised when the request concerns a team not owned by the connected user.

HTOpponentTeamIsTravellingError

Bases: HTChallengeError

Raised when opponent team is travelling and can't be challenged.

HTOpponentTeamNotAvailableError

Bases: HTChallengeError

Raised when opponent team is not available for a challenge.

HTSkillError

Bases: HTError

Raised when skill can't be well-defined.

HTTeamChallengingItself

Bases: HTChallengeError

Raised when a team is challenging itself.

HTTeamIsTravellingError

Bases: HTChallengeError

Raised when own team is travelling and can't challenge someone else.

HTTeamNotAvailableError

Bases: HTChallengeError

Raised when the own team is not available for a challenge.

For example when a friendly is already booked or the team is still in cup.

HTUnauthorizedAction

Bases: HTError

Raised when CHPP request returns a 401 error code.

HTUndefinedError

Bases: HTError

Raised when error occurs with Hattrick request.

HTUnknownActionTypeError

Bases: HTError

Raised when the requested action type is unknown.

HTUnknownMatchIdError

Bases: HTError

Raised when the requested match ID is unknown.

HTUnknownPlayerIdError

Bases: HTError

Raised when the requested player ID is unknown.

HTUnknownTeamIdError

Bases: HTError

Raised when the requested team ID is unknown.

HTUnknownYouthPlayerIdError

Bases: HTError

Raised when the requested youth player ID is unknown.

HTUnknownYouthTeamIdError

Bases: HTError

Raised when the requested youth team ID is unknown.

UnknownLeagueError

Bases: HTError

Raised when world league doesn't exist in the list.