Mercurial > hgrepos > Python > libs > ConfigMix
comparison doc/introduction.rst @ 97:1b4d95f60650
Build a tree-ish configuration from an INI style configuration file
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Sun, 18 Mar 2018 19:15:01 +0100 |
| parents | 2b79ddc0f92b |
| children | aa0c61e79660 |
comparison
equal
deleted
inserted
replaced
| 96:778c3bb1fb41 | 97:1b4d95f60650 |
|---|---|
| 24 ---------- | 24 ---------- |
| 25 | 25 |
| 26 Need the :mod:`yaml` package (e.g. ``pip install pyyaml``) | 26 Need the :mod:`yaml` package (e.g. ``pip install pyyaml``) |
| 27 | 27 |
| 28 .. note:: All strings are returned as Unicode text strings. | 28 .. note:: All strings are returned as Unicode text strings. |
| 29 | |
| 30 | |
| 31 An example is: | |
| 32 | |
| 33 .. literalinclude:: ../tests/data/conf10.yml | |
| 34 :language: yaml | |
| 29 | 35 |
| 30 | 36 |
| 31 .. _ini-files: | 37 .. _ini-files: |
| 32 | 38 |
| 33 INI Files | 39 INI Files |
| 61 .. note:: All strings are returned as Unicode text strings. | 67 .. note:: All strings are returned as Unicode text strings. |
| 62 | 68 |
| 63 .. note:: Contrary to the behaviour of the standard Python :mod:`configparser` | 69 .. note:: Contrary to the behaviour of the standard Python :mod:`configparser` |
| 64 module the INI file reader is *case-sensitive*. | 70 module the INI file reader is *case-sensitive*. |
| 65 | 71 |
| 66 .. todo:: Implement tree-ish interpretation of INI files | 72 .. todo:: Document the build of tree-ish configuration settings out of |
| 73 INI files. | |
| 67 | 74 |
| 68 Currently there is no tree. | 75 The example INI style configuration below yields an equivalent |
| 76 configuration to the YAML configuration above: | |
| 77 | |
| 78 .. literalinclude:: ../tests/data/conf10.ini | |
| 79 :language: ini | |
| 80 | |
| 81 As can be seen in thie example -- INI file internal value interpolation | |
| 82 is done as in Python's standard :mod:`configparser` module. | |
| 83 | |
| 84 This example also illustrates how INI sections are used to build a | |
| 85 tree-ish configuration dictionary. | |
| 69 | 86 |
| 70 | 87 |
| 71 .. _executable-python-scripts: | 88 .. _executable-python-scripts: |
| 72 | 89 |
| 73 Executable Python Scripts | 90 Executable Python Scripts |
| 88 This is analogous to as Python modules behave when importing them with | 105 This is analogous to as Python modules behave when importing them with |
| 89 ``from module import *``. | 106 ``from module import *``. |
| 90 | 107 |
| 91 .. note:: The Python configuration files are evaluated with ``exec`` and not | 108 .. note:: The Python configuration files are evaluated with ``exec`` and not |
| 92 imported. | 109 imported. |
| 110 | |
| 111 The example configuration by Python script below yields an equivalent | |
| 112 configuration to the YAML configuration above: | |
| 113 | |
| 114 .. literalinclude:: ../tests/data/conf10.py | |
| 115 :language: python |
