cozify.config

Module for handling consistent state storage.

cozify.config.state_file

file path where state storage is kept. By default XDG conventions are used. (Most likely ~/.config/python-cozify/python-cozify.cfg)

Type

str

cozify.config.state

State object used for in-memory state. By default initialized with _initState.

Type

configparser.ConfigParser

Module Contents

Functions

_initXDG()

Initialize config path per XDG basedir-spec and resolve the final location of state file storage.

stateWrite(tmpstate=None)

Write current state to file storage.

setStatePath(filepath=_initXDG(), copy_current=False)

Set state storage path. Useful for example for testing without affecting your normal state. Call with no arguments to reset back to autoconfigured location.

dump_state()

Print out current state file to stdout. Long values are truncated since this is only for visualization.

_initState(state_file)

Initialize state on cold start. Any stored state is read in or a new basic state is initialized.

Attributes

state_file

state

cozify.config._initXDG()

Initialize config path per XDG basedir-spec and resolve the final location of state file storage.

Returns

file path to state file as per XDG spec and current env.

Return type

str

cozify.config.stateWrite(tmpstate=None)

Write current state to file storage.

Parameters

tmpstate (configparser.ConfigParser) – State object to store instead of default state.

cozify.config.setStatePath(filepath=_initXDG(), copy_current=False)

Set state storage path. Useful for example for testing without affecting your normal state. Call with no arguments to reset back to autoconfigured location.

Parameters
  • filepath (str) – file path to use as new storage location. Defaults to XDG defined path.

  • copy_current (bool) – Instead of initializing target file, dump previous state into it.

cozify.config.dump_state()

Print out current state file to stdout. Long values are truncated since this is only for visualization.

cozify.config._initState(state_file)

Initialize state on cold start. Any stored state is read in or a new basic state is initialized.

Parameters

state_file (str) – State storage filepath to attempt to read from.

Returns

State object.

Return type

configparser.ConfigParser

cozify.config.state_file
cozify.config.state