Welcome to confattr’s documentation — confattr v0.7.0 documentation

# Welcome to confattr’s documentation

`confattr` (config attributes) is a python library to read and write config files with the following features:

- Static type checking of the code is possible with e.g. mypy.

- Values are checked and if the config file contains invalid syntax, unknown keys or invalid values a useful error messages is given to the user via a callback registered with `ConfigFile.set_ui_callback()`.

- It is possible to create a default config file with comments giving help and allowed values via `ConfigFile.save()`. [example]

- It is possible to generate a help via `ConfigFile.write_help()` and `ConfigFile.get_help()`. [example]

- Settings can be changed via environment variables, too. [example]

- It is easy to integrate into existing projects, just replace an existing attribute with a `Config` instance. For example, assume a class has the attribute `color = 'red'`. Replace it with `color = Config('color', 'red', allowed_values=['red', 'green', 'blue'])` and call `ConfigFile.load()` (after the attribute has been created but before it’s value is used). Then a user can create a config file in the `expected location` and can change the attribute with `set color=green`. You don’t need to change the usage of the attribute because `Config` implements the descriptor protocol.

- It is easy to add custom commands by subclassing `ConfigFileCommand`. [example]

- It can be used to parse single lines, e.g. from a command line, too, with `ConfigFile.parse_line()`.

- It is well documented.

- Includes an example for test automation. [example]

## Introduction and examples

- Introduction and examples
  - Config and ConfigFile
  - Config file syntax
  - Different values for different objects
  - Include
  - Generating help
  - Custom data types
  - Adding new commands to the config file syntax
  - Writing custom commands to the config file
  - Customizing the config file syntax
  - Config without classes
  - Testing your application
  - Environment variables

## Reference

- confattr package
  - Submodules
  - Module contents
- confattr.config module
  - `Config`
  - `ConfigTrackingChanges`
  - `DictConfig`
  - `InstanceSpecificDictMultiConfig`
  - `MultiConfig`
  - `MultiDictConfig`
- confattr.configfile module
  - `ArgumentParser`
  - `ConfigFile`
  - `ConfigFileArgparseCommand`
  - `ConfigFileCommand`
  - `ConfigFileWriter`
  - `DEFAULT_COMMAND`
  - `FormattedWriter`
  - `HelpWriter`
  - `Include`
  - `MultipleParseExceptions`
  - `NotificationLevel`
  - `ParseException`
  - `ParseLineKwargs`
  - `ParseSplittedLineKwargs`
  - `SaveKwargs`
  - `SectionLevel`
  - `Set`
  - `SortedEnum`
  - `TextIOWriter`
  - `UiNotifier`
  - `UnknownCommand`
  - `readable_quote()`
- confattr.subprocess_pipe module
  - `run_and_pipe()`
  - `split_list()`
- confattr.types module
  - `Path`
  - `Regex`
  - `SubprocessCommand`
  - `SubprocessCommandWithAlternatives`
- confattr.utils module
  - `HelpFormatter`
  - `HelpFormatterWrapper`

## Indices and tables

- Index

- Module Index

- Search Page

## Links

- Source code

- Bug tracker

- Change log

- PyPI