Mercurial > hgrepos > Python > libs > ConfigMix
comparison doc/introduction.rst @ 190:3d273eb13565
Doc: Adjust the example in the introduction to the new custom association style
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 03 May 2019 19:49:59 +0200 |
| parents | 1ff11462a5c1 |
| children | 70c4f81ac58c |
comparison
equal
deleted
inserted
replaced
| 189:0d0980ed74cc | 190:3d273eb13565 |
|---|---|
| 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.get_loader("*.yml")) | 355 configmix.set_assoc("*.conf", configmix.get_assoc("*.yml")) |
| 356 | 356 |
| 357 Allow only files with extension ".cfg" in INI-style -- using the default | 357 Allow only files with extension ".cfg" in INI-style -- using the default |
| 358 loader for INI-files:: | 358 loader for INI-files:: |
| 359 | 359 |
| 360 configmix.clear_loader() | 360 configmix.clear_assoc() |
| 361 configmix.set_loader("*.cfg", configmix.get_default_loader("*.ini")) | 361 configmix.set_assoc("*.cfg", configmix.get_default_assoc("*.ini")) |
| 362 | 362 |
| 363 Just a new configuration file style:: | 363 Just a new configuration file style:: |
| 364 | 364 |
| 365 def my_custom_loader(filename): | 365 def my_custom_loader(filename): |
| 366 ... | 366 ... |
| 367 return some_dict_alike | 367 return some_dict_alike |
| 368 | 368 |
| 369 configmix.clear_loader() | 369 configmix.mode_loaders["myconfmode"] = my_custom_loader |
| 370 configmix.set_loader("*.my.configuration", my_custom_loader) | 370 configmix.clear_assoc() |
| 371 configmix.set_assoc("*.my.configuration", "myconfmode") |
