Parameters#
Handling parameters for Python and CLI usage.
- class mosayc.parameters.Parameters(*, input: str, output: str, tiles_dir: str, scale: float, tilt: float, color_shift: float, quotas: int, root_dir: str)[source]#
Dataclass representing parameters for a mosaic.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- mosayc.parameters.default_parameters = {'color_shift': 100, 'input': 'main.jpeg', 'output': 'mosaic.jpeg', 'quotas': 3, 'root_dir': '.', 'scale': 3, 'tiles_dir': 'tiles', 'tilt': 10}#
Default values. Can be overriden by .mosayc config file or input values.
- mosayc.parameters.get_parameters(erase_config=False)[source]#
- Parameters:
erase_config (
bool
, default=False) – Restore config file with default values.- Returns:
Values to use.
- Return type:
Examples
If no config file is provided, the default parameters are used and a config file is created.
>>> p = get_parameters() >>> p Parameters(input='main.jpeg', output='mosaic.jpeg', tiles_dir='tiles', scale=3.0, tilt=10.0, color_shift=100.0, quotas=3, root_dir='.')
If the config file exists, its values are loaded.
>>> p.scale = .4 >>> conf_file = Path.home() / ".mosayc" >>> with open(conf_file, "wt", encoding="utf8") as f: ... yaml.dump(p.__dict__, f) >>> p = get_parameters() >>> p.scale 0.4
If erase_config is True, the config file is re-created with default values.
>>> p = get_parameters(erase_config=True) >>> p.scale 3.0