onix.collection.log_processor module

Functionality for processing of logs and routing parsed data to sinks

class onix.collection.log_processor.LogProcessor(moveset_sink, battle_info_sink, battle_sink, force_context_refresh=False)[source]

Bases: object

Executor in charge of processing battle logs and routing the parsed data to the appropriate sinks. The LogProcessor is in charge of instantiating “log readers” to process the logs that come in based on the format of the log (_e.g._ JSON file) and the metagame of the battle.

Parameters:
  • moveset_sink (sinks.MovesetSink) – The sink to route movesets data
  • battle_info_sink (sinks.BattleInfoSink) – The sink to route battle metadata
  • battle_sink (sinks.BattleSink) – The sink to route the actual turn-by-turn battle representations
  • force_context_refresh (bool, optional) – Defaults to False. If True, any contexts that get loaded will be pull fresh data from Pokemon Showdown rather than rely on the local cache.
process_logs(logs, ref_type='folder', error_handling='raise')[source]

Process the specified logs

Parameters:
  • logs – Reference to the logs to process
  • ref_type (str, optional) –

    Description of the logs parameter specifying how to handle it. Options are:

    • “file” : specifying a single JSON log
    • “files” : specifying an iterable of JSON logs
    • “folder” : specifying a directory or nested directory of JSON logs

    Defaults to “folder”

  • error_handling (str, optional) –

    The strategy for handling log-parsing errors. Options are:

    • “raise” : raise an exception if an error is encountered.
    • “warn” : report the exception as a warning, then keep going
    • “skip” : silently skip problematic logs

    Defaults to “raise”

Returns:

the number of logs processed successfully

Return type:

int