Args

Inheritance diagram of src.args

Provides classes and functions for parsing and validating command-line arguments.

module:

args

author:

Le Bars, Yoann

class src.args.CmdLineArgs(**kwargs)[source]

Bases: Namespace

Holds and parses command-line arguments.

Variables:
  • n_iter (int) – Number of iterations.

  • n_bodies (int) – Number of bodies.

  • dens (float) – Object density.

  • dt (float) – Model time step (in s).

  • universal_g (float) – Universal gravity constant (in m³/kg/s²).

  • epsilon (float) – Computing precision.

  • seed (int) – Seed for random number generation.

  • debug_console (bool) – Whether to enable logs through the standard output.

  • debug_file (str | None) – File path for logging.

  • debug_syslog (str | None) – Identifier for syslog logging.

  • log_level (LogLevel) – Log level filter.

debug_console: bool = False
debug_file: str | None = None
debug_syslog: str | None = None
dens: float = 0.1
dt: float = 0.5
epsilon: float = 1e-06
log_freq: int = 100
log_level: LogLevel = 'critical'
n_bodies: int = 20
n_iter: int = 500
classmethod parse(app: QApplication, argv: list[str] | None = None) CmdLineArgs[source]

Parses and validates command-line arguments.

This method is decoupled from QApplication for better modularity. The help strings are intentionally not translated, as command-line interfaces are typically expected to be in English.

Parameters:
  • app (QApplication) – The application instance, used for translations.

  • argv (list[str] | None) – Command-line arguments to parse. Defaults to sys.argv[1:].

Returns:

An initialised instance of CmdLineArgs.

seed: int = 0
show_alpha_arrow: bool = False
show_torque_arrow: bool = False
universal_g: float = 6.6743e-11
validate() None[source]

Validates the arguments.

exception src.args.CmdLineValidationError(message: str, code: ExitCode)[source]

Bases: Exception

Exception for command line validation errors.

class src.args.ExitCode(*values)[source]

Bases: IntEnum

Exit codes for the application.

CMD_LINE_ERROR = -1
MISSING_ABOUT_FILE = -2
NEGATIVE_DENSITY = -5
NEGATIVE_EPSILON = -8
NEGATIVE_GRAVITY = -7
NEGATIVE_LOG_FREQ = -10
NEGATIVE_SEED = -9
NEGATIVE_TIME_STEP = -6
NOT_ENOUGH_BODIES = -4
NOT_ENOUGH_ITERATIONS = -3
SUCCESS = 0
UNKNOWN_EXCEPTION = -11
class src.args.LogLevel(*values)[source]

Bases: Enum

Log level for the application.

CRITICAL = 'critical'
DEBUG = 'debug'
FATAL = 'fatal'
INFO = 'info'
WARNING = 'warning'