rcmpy.state package — docs

Skip to main content
`Ctrl`+`K`

# rcmpy.state package

## Module contents

A module implementing this package’s stateful information that persists across invocations.

class rcmpy.state.State(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)

  Bases: `RcmpyDictCodec`

  The top-level configuration object for the package.

  asdict() → dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]]

    Obtain a dictionary representing this instance.

  configs_new: bool
  directory: Path
  init(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]]) → None

    Perform implementation-specific initialization.

  is_new() → bool

    Determine if state has changed.

  manifest: Dict[str, Any]
  manifest_new: bool
  root_directories(subdir: str, common_first: bool = True) → List[Path]

    Get up to a pair of directories from some sub-directory of the current root.

  set_directory(path: Path | str | None) → None

    Set a new directory to use as the data repository.

  set_variant(variant: str = None) → None

    Set a new variant value.

  update_manifest(data: Dict[str, Any]) → None

    Set new manifest data.

  variables_new: bool
  variant: str

rcmpy.state.load_state(root: Path | str | None = None, name: str = 'state.json') → Iterator[State]

  This needs to be a context manager, so it get’s written back to disk.