pymetacode.configuration module¶
Configuration handling of the pymetacode package.
Key to the rather simplistic and user-friendly command-line interface (CLI)
of the pymetacode package is a configuration stored within the
package root directory and read by all the code generators residing in the
pymetacode.coding
module.
The Configuration
class provides the necessary functionality for
creating a default configuration file as well as for reading the
configuration from a file for use with the code generators.
- class pymetacode.configuration.Configuration¶
Bases:
pymetacode.utils.ToDictMixin
Configuration used for generating code.
A necessary prerequisite for all the code generators is a minimal set of configuration values that are persistently stored in a file within the project root directory and read from there accordingly.
The class provides the unique place to structure this configuration.
- Raises
ValueError – Raised if no dict is provided.
Examples
The following examples demonstrate how to use the CLI from the terminal, rather than how to use this class programmatically.
The first step when creating a new package is to write a config file that can be filled with sensible content afterwards:
pymeta write config to mypackage_config.yaml
This would write the default configuration to “mypackage_config.yaml”. Change all values in this file according to your needs.
Changed in version 0.3: New property “options”, moved key “git” to property “options”
- from_dict(dict_=None)¶
Set attributes from dictionary.
- Parameters
dict (
dict
) – Dictionary containing information of a task.- Raises
ValueError – Raised if no dict is provided.
- from_file(name='')¶
Read from YAML file.
- Parameters
name (
str
) – Name of the YAML file to read from.
- to_dict()¶
Create dictionary containing public attributes of an object.
- Returns
public_attributes – Ordered dictionary containing the public attributes of the object
The order of attribute definition is preserved
- Return type