Mercurial > hgrepos > Python > libs > ConfigMix
comparison doc/introduction.rst @ 171:1ff11462a5c1
The associations from filename extensions to parsers are "fnmatch" style patterns now.
Calling "configmix.set_loader" prepends to the currently defined
associations and therefore gets the highest priority.
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Thu, 25 Apr 2019 17:00:09 +0200 |
| parents | 4643763b39ee |
| children | 3d273eb13565 |
comparison
equal
deleted
inserted
replaced
| 170:c247a5dc35ed | 171:1ff11462a5c1 |
|---|---|
| 350 for custom configuration files you have various possibilities: | 350 for custom configuration files you have various possibilities: |
| 351 | 351 |
| 352 Associate an additional new extension (e.g. ".conf") with an | 352 Associate an additional new extension (e.g. ".conf") with an |
| 353 existing configuration file style (e.g. YAML):: | 353 existing configuration file style (e.g. YAML):: |
| 354 | 354 |
| 355 configmix.set_loader(".conf", configmix.default_loaders[".yml"]) | 355 configmix.set_loader("*.conf", configmix.get_loader("*.yml")) |
| 356 | 356 |
| 357 Allow only files with extension ".cfg" in INI-style:: | 357 Allow only files with extension ".cfg" in INI-style -- using the default |
| 358 loader for INI-files:: | |
| 358 | 359 |
| 359 configmix.clear_loader() | 360 configmix.clear_loader() |
| 360 configmix.set_loader(".cfg", configmix.default_loders[".ini"]) | 361 configmix.set_loader("*.cfg", configmix.get_default_loader("*.ini")) |
| 361 | 362 |
| 362 Just a new configuration file style:: | 363 Just a new configuration file style:: |
| 363 | 364 |
| 364 def my_custom_loader(filename): | 365 def my_custom_loader(filename): |
| 365 ... | 366 ... |
| 366 return some_dict_alike | 367 return some_dict_alike |
| 367 | 368 |
| 368 configmix.clear_loader() | 369 configmix.clear_loader() |
| 369 configmix.set_loader(".my.configuration", my_custom_loader) | 370 configmix.set_loader("*.my.configuration", my_custom_loader) |
