Mercurial > hg > configuration
comparison README.txt @ 74:0516a9e0566b
more README hacking
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Wed, 28 Mar 2012 12:42:58 -0700 |
| parents | 79f2d70ed5e5 |
| children | 6667e79ffcb3 |
comparison
equal
deleted
inserted
replaced
| 73:79f2d70ed5e5 | 74:0516a9e0566b |
|---|---|
| 7 configuration files (I currently support JSON and YAML) and also | 7 configuration files (I currently support JSON and YAML) and also |
| 8 from the command line | 8 from the command line |
| 9 - you want to be able to serialize and deserialize configuration | 9 - you want to be able to serialize and deserialize configuration |
| 10 | 10 |
| 11 | 11 |
| 12 API | 12 Basic Usage |
| 13 --- | 13 ----------- |
| 14 | 14 |
| 15 The ``configuration.Configuration`` class implements an abstract base | 15 The ``configuration.Configuration`` class implements an abstract base |
| 16 class that extends ``optparse.OptionParser``. The form of the | 16 class that extends ``optparse.OptionParser``. The form of the |
| 17 configuration is dictated by setting the ``options`` attribute on your | 17 configuration is dictated by setting the ``options`` attribute on your |
| 18 subclass. ``options`` is a dictionary of the form:: | 18 subclass. ``options`` is a dictionary of the form:: |
| 52 The latter is only useful if the configuration contains nothing | 52 The latter is only useful if the configuration contains nothing |
| 53 machine-specific (e.g. the path to an executable might vary from | 53 machine-specific (e.g. the path to an executable might vary from |
| 54 machine to machine) or if the configuration is overridable from the | 54 machine to machine) or if the configuration is overridable from the |
| 55 command line. | 55 command line. |
| 56 | 56 |
| 57 ``configure`` features the ability to serialize (dump) and deserialize | 57 ``configuration`` features the ability to serialize (dump) and deserialize |
| 58 (load) configuration from a pluggable set of formats. | 58 (load) configuration from a pluggable set of formats. By default, |
| 59 ``--dump <filename>`` will dump the resultant configuration (that | |
| 60 gathered from the command line options and loaded configuration files) | |
| 61 to a file of format dictate by the file extension (Example: | |
| 62 ``--dump mydumpfile.json`` will use JSON format). The flag for the | |
| 63 option, e.g. ``--dump``, may be set via the ``dump`` parameter to | |
| 64 ``Configuration``'s constructor. | |
| 65 | |
| 66 ``Configuration`` instances can also deserialize data. The normal case of | |
| 67 using configuration is when you want to be able to read from | |
| 68 configuration files. By default, ``Configuration`` instances read | |
| 69 positional arguments for configuration files to be loaded. | |
| 59 | 70 |
| 60 The `configuration package <http://pypi.python.org/pypi/configuration>`_ | 71 The `configuration package <http://pypi.python.org/pypi/configuration>`_ |
| 61 requires ``json``(``simplejson`` on older python) and ``PyYAML`` so | 72 requires ``json``(``simplejson`` on older python) and ``PyYAML`` so |
| 62 these serializers/deserializers are available if you install the package. | 73 these serializers/deserializers are available if you install the package. |
| 74 | |
| 75 | |
| 76 Extending Configuration | |
| 77 ----------------------- | |
| 63 | 78 |
| 64 ---- | 79 ---- |
| 65 | 80 |
| 66 Jeff Hammel | 81 Jeff Hammel |
| 67 | 82 |
