gnomish_army_knife.database package#

Submodules#

gnomish_army_knife.database.combat_log module#

A module implementing a combat-log state data structure.

class gnomish_army_knife.database.combat_log.CombatLogState(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] = None, schemas: SchemaMap = None, dest_attr: str = 'data', verify: bool = True)[source]#

Bases: GakDictCodec, BasicDictCodec, LoggerMixin

The top-level configuration object for the package.

property files: dict[str, Any]#

Get combat log file data.

init(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]]) None[source]#

Initialize this instance.

process_event(key: str, event: CombatLogEvent) None[source]#

Process a combat-log event.

process_line(key: str, line: str, log_date: datetime) None[source]#

Process a line from a combat log file.

process_log(path: Path, stop: Event = None) None[source]#

Process a combat log file.

gnomish_army_knife.database.event module#

A module implementing interfaces for combat log events.

class gnomish_army_knife.database.event.CombatLogEvent(timestamp: datetime, name: str, data: list[str], line: str)[source]#

Bases: NamedTuple

A simple container for combat log events.

as_json() dict[str, Any][source]#

Create a JSON serializable dictionary from this instance.

data: list[str]#

Alias for field number 2

static from_json(data: dict[str, Any]) CombatLogEvent[source]#

Create an event from JSON message data.

static from_line(line: str) CombatLogEvent[source]#

Create an event from a string line.

line: str#

Alias for field number 3

log(logger: Logger | LoggerAdapter[Any], level: int = 20) None[source]#

Log this event.

static log_handler(logger: Logger | LoggerAdapter[Any]) Callable[[CombatLogEvent], None][source]#

Create a simple event handler.

name: str#

Alias for field number 1

timestamp: datetime#

Alias for field number 0

gnomish_army_knife.database.event.parse_timestamp(data: str) datetime[source]#

Parse a timestamp string from a combat log line.

gnomish_army_knife.database.meta module#

A module implementing an arena-match metadata interface.

class gnomish_army_knife.database.meta.ArenaMatchMetadata[source]#

Bases: LoggerMixin

A class implementing an arena-match metadata interface.

file_path(base: Path, suffix: str = '.txt') Path | None[source]#

Get a file path this match could be written to. This path should be unique for any match that occurs on live servers.

handle(event: CombatLogEvent) bool[source]#

Attempt to glean new metadata from this event. Returns whether or not the end of a match has been captured.

reset() None[source]#

Reset metadata state.

property summary: str#

A summary string for this match.

gnomish_army_knife.database.queue module#

A module implementing a simple queue-handler event interface.

class gnomish_army_knife.database.queue.CombatLogQueueHandler[source]#

Bases: object

A simple mixin class for handling combat log events via per-event handlers and queue handlers.

handle(event: CombatLogEvent) None[source]#

Handle a combat-log event.

register(queue: Queue[CombatLogEvent]) int[source]#

Register a queue.

registered(queue: Queue[CombatLogEvent]) Iterator[None][source]#

Register a queue as a managed context.

remove(index: int) bool[source]#

Remove a previously registered queue.

gnomish_army_knife.database.writer module#

A module implementing an arena-match file-writing interface.

class gnomish_army_knife.database.writer.ArenaMatchWriter(root: Path | str | None)[source]#

Bases: LoggerMixin

A class capable of writing individual arena match events to disk.

async handle(event: CombatLogEvent) bool[source]#

Returns true if the arena-match-writer consumed the event.

Module contents#

A module implementing a database interface for the package.

class gnomish_army_knife.database.ArenaMatchDb(stack: ExitStack, root: Path)[source]#

Bases: LoggerMixin

A class implementing a top-level program database interface.

property combat_log_state_path: Path#

Get the path to the combat-log state data.

create_writer() ArenaMatchWriter[source]#

Create an arena-match writer interface.

data_path(name: str) Path[source]#

Get the path to a data file.

ext = 'json'#
property matchdb_path: Path#

The path to the matchdb directory.