ogd.core.exec package

Submodules

ogd.core.exec.Commands module

Module containing all the commands available through the OGD CLI

class ogd.core.exec.Commands.OGDCommands[source]

Bases: object

Utility class to collect functions for each of the commands that can be run when executing ogd-core as a module.

static ListGames(games_list: List[str]) bool[source]

Command to list out the games available for export.

Parameters:

games_list (List[str]) – The list of available games, which the command should display.

Returns:

True if the list was successfully displayed, else False.

Return type:

bool

static RunExport(args: Namespace, config: ConfigSchema, destination: Path, with_events: bool = False, with_features: bool = False) bool[source]

Function to handle execution of export code. This is the main intended use of the program.

Parameters:
  • events (bool, optional) – _description_, defaults to False

  • features (bool, optional) – _description_, defaults to False

Returns:

_description_

Return type:

bool

Todo

Make use of destination parameter

Todo

Refactor “step 2” logic into smaller functions, probably a “get case”, then pass in to a “get range” and “get dataset ID”

static ShowGameInfo(config: ConfigSchema, game: str) bool[source]

Function to print out info on a game from the game’s schema. This does a similar function to writeReadme, but is limited to the CSV metadata part (basically what was in the schema, at one time written into the csv’s themselves). Further, the output is printed rather than written to file.

return:

True if game metadata was successfully loaded and printed, or False if an error occurred

rtype:

bool

static WriteReadme(config: ConfigSchema, game: str, destination: Path) bool[source]

Function to write out the readme file for a given game. This includes the CSV metadata (data from the schema, originally written into the CSV files themselves), custom readme source, and the global changelog. The readme is placed in the game’s data folder.

return:

_description_

rtype:

bool

ogd.core.exec.Generators module

Module for generating certain objects for internal use in the OGD CLI

class ogd.core.exec.Generators.OGDGenerators[source]

Bases: object

Utility class to collect functions for generating objects used to execute certain commands.

Essentially, just a collection of random stuff that we didn’t want cluttering other files.

static GenDBInterface(config: ConfigSchema, game: str) EventInterface[source]

Create a data interface based on a config and desired game.

Parameters:
  • config (ConfigSchema) – The current OGD configuration

  • game (str) – The ID of the game whose data should be retrieved from the interface

Raises:
  • Exception – If the configuration for the given game does not give a valid type of database for the source.

  • ValueError – If the given game does not exist in the GameSourceMap of the given configuration.

Returns:

A data interface for the configured type of database.

Return type:

EventInterface

Todo

Accept a GameSourceSchema instead of a full ConfigSchema

Todo

Use the “upper” of the source type, instead of checking for capitalized and non-capitalized versions of names.

static GenDateRange(game: str, interface: EventInterface, monthly: bool, start_date: str, end_date: str | None) ExporterRange[source]

Use a pair of date strings to create an ExporterRange for use with an interface.

Also allows the range to be specified as “monthly,” i.e. to treat the “start date” as a specification of a full month for the range. Note that ExporterRange objects carry data about the sessions contained within the range, so an interface is required in order to create the session list.

Parameters:
  • game (str) – The specific game for which a date range is generated

  • interface (EventInterface) – An interface to use for generation of the ExporterRange.

  • monthly (bool) – Whether the range should cover a full month, or use the exact given start and end.

  • start_date (str) – A string representing the first day of the range in MM/DD/YYYY format, or the month to use for the range in MM/YYYY format.

  • end_date (Optional[str]) – A string representing the last day of the range in MM/DD/YYYY format, or None (if using a full month range)

Raises:

ValueError – If using full month range, and start_date does not have a correct format.

Returns:

An ExporterRange object representing the given range, as well as the sessions available for that range via the given interface.

Return type:

ExporterRange

Todo

Don’t include game as param, it’s only used in outputs, which should not be included here.

Todo

Add some try-except logic around the int(…) calls.

Todo

Add logic to check for yyyymmdd in addition to mmddyyyy.

Todo

Add logic to check for - separators, in addition to /.

static GenModes(with_events: bool, with_features: bool, no_session_file: bool, no_player_file: bool, no_pop_file: bool) Set[ExportMode][source]

Convert a series of booleans for each type of export mode into a set of ExportMode enum values.

Parameters:
  • with_events (bool) – Whether to include EVENTS and DETECTORS in the set

  • with_features (bool) – Whether to include any feature types in the set

  • no_session_file (bool) – Whether to include SESSION in the set

  • no_player_file (bool) – Whether to include PLAYER in the set

  • no_pop_file (bool) – Whether to include POPULATION in the set

Returns:

A set of ExportModes, based on the arguments

Return type:

Set[ExportMode]

ogd.core.exec.Parsers module

Module for setting up parsers for the OGD CLI

class ogd.core.exec.Parsers.OGDParsers[source]

Bases: object

Utility class to collect functions for setting up each of the parsers that are used by the various commands.

static CommandParser(games_list: List[str]) ArgumentParser[source]

Create an arg parser for getting top-level command.

Available commands are: * export * export-events * export-features * info * readme * list-games

Parameters:

games_list (List[str]) – List of games available for export.

Returns:

A parser that recognizes the available top-level commands

Return type:

ArgumentParser

static DestinationParser() ArgumentParser[source]

Create an arg parser for getting a destination parameter for various commands.

Available parameters are:

  • –destination

Returns:

A parser that recognizes the available destination parameter.

Return type:

ArgumentParser

static ExportParser(parents: List[ArgumentParser]) ArgumentParser[source]

Create an arg parser for getting parameters specific to export commands.

Available parameters are: * start_date * end_date * –player * –session * –player_id_file * –session_id_file * –file * –monthly * –no_session_file * –no_player_file * –no_pop_file

Parameters:

parents (List[ArgumentParser]) – The parent parser(s) that the export parsers contributes to.

Returns:

A parser that recognizes the available export parameters.

Return type:

ArgumentParser

static GameParser(games_list: List[str]) ArgumentParser[source]

Create an arg parser for getting a game parameter for various commands

Available parameters are:

  • game

Parameters:

games_list (List[str]) – List of games available for export.

Returns:

A parser that recognizes the available game parameter.

Return type:

ArgumentParser

Module contents

Initializer for CLI execution module