Internal Python API¶
Configuration¶
Logging configuration routines.
Errors¶
Escaping Formatter¶
- class sr.comp.http.escaping_formatter.EscapingFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]¶
Bases:
logging.Formatter
A class that formats log output nicely.
- format(record: logging.LogRecord) str [source]¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
JSON Encoder¶
Manager¶
Routines for managing a Compstate instance.
- sr.comp.http.manager.update_lock(compstate_path: str) Iterator[None] [source]¶
Acquire a lock on the given compstate for the purposes of updating it.
- Returns
A context manager object which will remove the lock when __exit__ed and, if a clean exit, touch the update file. In turn that triggers the manager to re load the information it has.
Query Utilities¶
Various utils for working with HTTP.
- class sr.comp.http.query_utils.KnockoutMatchScore[source]¶
Bases:
typing_extensions.TypedDict
- game: Mapping[sr.comp.types.TLA, sr.comp.types.GamePoints]¶
- normalised: Mapping[sr.comp.types.TLA, league_ranker.LeaguePoints]¶
- ranking: Mapping[sr.comp.types.TLA, league_ranker.RankedPosition]¶
- class sr.comp.http.query_utils.LeagueMatchScore[source]¶
Bases:
typing_extensions.TypedDict
- game: Mapping[sr.comp.types.TLA, sr.comp.types.GamePoints]¶
- league: Mapping[sr.comp.types.TLA, league_ranker.LeaguePoints]¶
- ranking: Mapping[sr.comp.types.TLA, league_ranker.RankedPosition]¶
- class sr.comp.http.query_utils.MatchInfo[source]¶
Bases:
sr.comp.http.query_utils._MatchInfo
- arena: sr.comp.types.ArenaName¶
- num: sr.comp.types.MatchNumber¶
- sr.comp.http.query_utils.match_json_info(comp: sr.comp.comp.SRComp, match: sr.comp.match_period.Match) sr.comp.http.query_utils.MatchInfo [source]¶
Get match JSON information.
- sr.comp.http.query_utils.parse_difference_string(string: str, type_converter: Callable[[str], sr.comp.http.query_utils.TParseable]) Callable[[sr.comp.http.query_utils.TParseable], bool] [source]¶
- sr.comp.http.query_utils.parse_difference_string(string: str, type_converter: Callable[[str], int] = int) Callable[[int], bool]
Parse a difference string (x..x, ..x, x.., x) and return a function that accepts a single argument and returns
True
if it is in the difference.
Server¶
- sr.comp.http.server.error_handler(e: werkzeug.exceptions.HTTPException) Union[werkzeug.exceptions.HTTPException, tuple[flask.wrappers.Response, int]] [source]¶