haniwers.v1.config.generator#

This module handles the generation of configuration files for haniwers. It creates starter configuration files based on templates.

Usage:

haniwers init [--force] [--no-env]

Module Contents#

Classes#

ConfigKind

Types of configuration files that can be generated.

ConfigGenerator

Functions#

find_template

Find a template file in possible locations.

create_file_from_template

Create a file from a template.

API#

class haniwers.v1.config.generator.ConfigKind#

Bases: str, enum.Enum

Types of configuration files that can be generated.

This enum inherits from str to all:

  1. Direct string comparison (kind == “all”)

  2. Automatic string conversion (str(kind))

  3. Easy conversion from string input (ConfigKind(“all”))

Initialization

Initialize self. See help(type(self)) for accurate signature.

ALL#

‘all’

CONFIG#

‘config’

ENV#

‘env’

haniwers.v1.config.generator.find_template(template_name: str) pathlib.Path | None#

Find a template file in possible locations.

Args: template_name (str): Name of the template file.

Returns: Path | None: Path to the template if found, None otherwise.

haniwers.v1.config.generator.create_file_from_template(template_name: str, dest_path: pathlib.Path, force: bool = False, replacements: dict[str, str] | None = None, header_comment: str | None = None) bool#

Create a file from a template.

Args: template_name (str): Name of the template file. dest_path (Path): Destination path for the file. force (bool): If True, overwrite existing file without confirmation. replacements (dict[str, str] | None): Dictionary of text replacements to apply. header_comment (str | None): Header comment to add to the file.

Returns: bool: True if successful, False otherwise.

class haniwers.v1.config.generator.ConfigGenerator(force: bool = False)#

Initialization

run(kind: haniwers.v1.config.generator.ConfigKind = ConfigKind.ALL) None#
create_config_file() bool#
create_env_file() bool#