Modules#

An overview of the modules that make up hwid. The API reference below is generated automatically from the source docstrings.

Public API (hwid.core)#

The package exposes hwid.get_hwid() at the top level.

Core engine for HWID: resolution logic, per-OS backends, errors, logging.

hwid.core.get_hwid()[source]#

Get the hardware ID of the current machine.

Returns:

The hardware ID string.

Return type:

str

Raises:
hwid.core.validate_hwid(value)[source]#

Validate if a string matches the HWID format.

Parameters:
  • value – The string to validate.

  • value (str)

Returns:

True if valid, False otherwise.

Return type:

bool

Exceptions (hwid.core.exceptions)#

Exceptions for the HWID package.

exception hwid.core.exceptions.InvalidHWIDError[source]#

Bases: Exception

Raised when the hardware ID is invalid.

exception hwid.core.exceptions.UnsupportedOSError[source]#

Bases: Exception

Raised when the operating system is not supported.

Logging (hwid.core.logging_setup)#

Set up logging for the project.

This module configures logging for the project, ensuring that log handlers are only added once to prevent duplicate log entries if the module is imported multiple times.

Setup is resilient to a read-only or unavailable $HOME: if the log directory cannot be created it degrades to console-only logging instead of raising, so read-only commands (--help, version) stay usable.

hwid.core.logging_setup.get_logger()[source]#

Return the cached project logger.

Returns:

The cached project logger.

Return type:

logging.Logger

hwid.core.logging_setup.setup_logger()[source]#

Set up and return the main logger for the project.

Ensures that handlers are only added once to avoid duplicate log entries if this module is imported multiple times.

Returns:

Configured logger for the project.

Return type:

logging.Logger

CLI (hwid.cli)#

argparse command-line interface exposing version and info commands.

CLI application for the project.

A dependency-free argparse root for the hwid command. It exposes the same version / info commands as the Typer variant and hangs every enabled non-primary component off the root as a lazily-imported subcommand — hwid interactive (TUI), hwid web, … — rather than a separate hwid-<name> console script (see ADR-019 and ADR-020). Selected via cli_framework.

hwid.cli.app.app(argv=None)[source]#

Run the hwid CLI application.

Parameters:
  • argv – Optional argument vector; defaults to sys.argv[1:] when None.

  • argv (list[str] | None)

Return type:

None

hwid.cli.app.info()[source]#

Display information about the hwid application.

Show application information:

hwid info

Example output:

Application Version: 0.1.0 Python Version: 3.12.0 (CPython) Platform: Darwin

Raises:

SystemExit – With code 1 if the package metadata cannot be found.

Return type:

None

hwid.cli.app.show_version()[source]#

Show the current version number of hwid.

Show the version number:

hwid version

Example output:

0.1.0

Raises:

SystemExit – With code 1 if the package metadata cannot be found.

Return type:

None