~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/util/configobj/docs/configobj.txt

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-02-06 01:45:28 UTC
  • mfrom: (3211.5.4 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080206014528-rb8v4hl04mgxulb7
(robertc) Tune RemoteRepository.get_parent_map to not send duplicate
        results, and to compress the data,
        reducing round trips further. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
----------------------------------------
8
8
 
9
9
:Authors: Michael Foord, Nicola Larosa
10
 
:Version: ConfigObj 4.0.0
11
 
:Date: 2005/10/17
 
10
:Version: ConfigObj 4.4.0
 
11
:Date: 2007/02/04
12
12
:Homepage: `ConfigObj Homepage`_
13
13
:Sourceforge: Sourceforge_
 
14
:Development: `SVN Repository`_
14
15
:License: `BSD License`_
15
16
:Support: `Mailing List`_
16
17
 
17
18
.. _Mailing List: http://lists.sourceforge.net/lists/listinfo/configobj-develop
 
19
.. _SVN Repository: http://svn.pythonutils.python-hosting.com
18
20
 
19
21
.. meta::
20
22
   :description: ConfigObj - a Python module for easy reading and writing of 
32
34
file round tripper*. Its main feature is that it is very easy to use, with a
33
35
straightforward programmer's interface and a simple syntax for config files.
34
36
It has lots of other features though :
35
 
 
 
37
    
36
38
* Nested sections (subsections), to any level
37
39
* List values
38
40
* Multiple line values
39
41
* String interpolation (substitution)
40
42
* Integrated with a powerful validation system
41
43
 
42
 
    * including automatic type checking/conversion
43
 
    * repeated sections
44
 
    * and allowing default values
 
44
    - including automatic type checking/conversion
 
45
    - repeated sections
 
46
    - and allowing default values
45
47
 
46
48
* All comments in the file are preserved
47
49
* The order of keys/sections is preserved
48
50
* No external dependencies
49
 
 
50
 
ConfigObj 4 is a complete rewrite of ConfigObj. A great deal has been
51
 
simplified and improved [#]_ since ConfigObj 3. If you have used ConfigObj
52
 
before then you need to read the section on `backwards compatibility`_.
53
 
 
54
 
ConfigObj now has a barrage [#]_ of doctests built into it, testing almost every
55
 
feature. Run ``python configobj.py -v`` to see them in action. Despite the tests,
56
 
ConfigObj 4 is actually smaller than version 3 and has no external dependencies.
 
51
* Full Unicode support
 
52
* A powerful ``unrepr`` mode for storing basic datatypes
 
53
 
 
54
ConfigObj has a barrage of doctests [#]_ built into it, testing almost every
 
55
feature. Run ``python configobj_test.py -v`` to see them in action.
57
56
 
58
57
For support and bug reports please use the ConfigObj `Mailing List`_.
59
58
 
60
 
.. hint::
61
 
 
62
 
    There is an article on using `ConfigObj for Data Persistence`_.
63
 
    
64
 
    The code from that article is available as ConfigPersist.py_.
65
59
 
66
60
.. _ConfigObj for Data Persistence: http://www.voidspace.org.uk/python/articles/configobj_for_data_persistence.shtml
67
61
.. _ConfigPersist.py: http://www.voidspace.org.uk/python/configpersist.html
68
62
 
 
63
 
69
64
Downloading
70
65
===========
71
66
 
72
 
The current version is **4.0.0**, dated 17th October 2005. ConfigObj 4 is
73
 
now stable. We may still expect to pick up a few bugs along the way though [#]_.
 
67
The current version is **4.4.0**, dated 4th February 2007. ConfigObj 4 is
 
68
now stable. We still expect to pick up a few bugs along the way though [#]_.
74
69
{sm;:-)}
75
70
 
76
71
You can get ConfigObj in the following ways :
111
106
various other useful modules, and is required by many of the `Voidspace Python
112
107
Projects`_.
113
108
 
 
109
Development Version
 
110
-------------------
 
111
 
 
112
It is sometimes possible to get the latest *development version* of ConfigObj
 
113
from the `Subversion Repository <http://svn.pythonutils.python-hosting.com/trunk/pythonutils/>`_.
 
114
 
114
115
.. _configobj.py: http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj.py
115
 
.. _configobj.zip: http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.0.0.zip
 
116
.. _configobj.zip: http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj-4.4.0.zip
116
117
.. _validate.py: http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=validate.py
117
118
.. _API Docs: http://www.voidspace.org.uk/python/configobj-api/
118
119
.. _this document:
119
120
.. _configobj homepage: http://www.voidspace.org.uk/python/configobj.html
120
 
.. _Subversion Repository: http://svn.rest2web.python-hosting.com/branches/configobj4
121
121
.. _Sourceforge: http://sourceforge.net/projects/configobj
122
122
.. _EpyDoc: http://epydoc.sourceforge.net
123
123
.. _pythonutils: http://www.voidspace.org.uk/python/pythonutils.html
124
124
.. _Voidspace Python Projects: http://www.voidspace.org.uk/python
125
125
 
 
126
 
 
127
 
 
128
ConfigObj in the Real World
 
129
===========================
 
130
    
 
131
Projects that use **ConfigObj** include :
 
132
 
 
133
* `Bazaar <http://bazaar-ng.org>`_.
 
134
 
 
135
    Bazaar is a Python distributed {acro;VCS;Version Control System}.
 
136
    ConfigObj is used to read ``bazaar.conf`` and ``branches.conf``.
 
137
 
 
138
* `Turbogears <http://www.turbogears.org/>`_
 
139
 
 
140
    Turbogears is a web application framework.
 
141
 
 
142
* `Chandler <http://chandler.osafoundation.org/>`_
 
143
 
 
144
   A Python and `wxPython <http://www.wxpython.org>`_ 
 
145
   {acro;PIM;Personal Information Manager}, being developed by the 
 
146
   `OSAFoundation <http://www.osafoundation.org/>`_.
 
147
 
 
148
* `CryptoBox <https://systemausfall.org/trac/cryptobox/wiki/CryptoBox/en>`_
 
149
 
 
150
   A very interesting looking Debian based Live-CD which supports storing 
 
151
   data using an encrypted harddisk; usable even by non technical users.
 
152
 
 
153
* `Simple64 <http://ubuntuforums.org/showthread.php?t=266290>`_
 
154
 
 
155
    A Ubuntu tool which provides a GUI to install a host of applications.
 
156
 
 
157
* `Debian-cd-ng <http://wiki.debian.org/debian-cd-ng>`_
 
158
 
 
159
    *Debian-cd-ng* recommends ConfigObj for parsing the Debian-cd configuration files.
 
160
 
 
161
* `NeuroImaging in Python <http://projects.scipy.org/neuroimaging/ni/wiki>`_
 
162
 
 
163
    BrainSTAT is a project with the ultimate goal to produce a
 
164
    platform-independent python environment for the analysis of brain
 
165
    imaging data.
 
166
    
 
167
* `Gruik <http://www.tracos.org/gruik/wiki>`_
 
168
 
 
169
    Gruik is a free software network packet sniffer.
 
170
 
 
171
 
126
172
Getting Started
127
173
===============
128
174
 
267
313
    # The 'final_comment'
268
314
    # Which also may be several lines
269
315
 
 
316
 
270
317
ConfigObj specifications
271
318
========================
272
319
 
291
338
  the options_ ``file_error`` and ``create_empty``. The filename will be
292
339
  preserved as the ``filename`` attribute. This can be changed at any time.
293
340
 
294
 
* A list of lines. Any trailing ``\n`` will be removed from the lines. The
 
341
* A list of lines. Any trailing newlines will be removed from the lines. The
295
342
  ``filename`` attribute of your ConfigObj will be ``None``.
296
343
 
297
 
* A ``StringIO`` instance or file object, or any object with ``seek`` and
298
 
  ``read`` methods. The object you pass in will be preserved as the
299
 
  ``filename`` attribute of your ConfigObj. If it has a ``write`` method [#]_
300
 
  then you can use the ConfigObj ``write`` method. Note that a file object
301
 
  passed in won't have its ``close`` method called by ConfigObj.
 
344
* A ``StringIO`` instance or file object, or any object with a ``read`` method.
 
345
  The ``filename`` attribute of your ConfigObj will be ``None`` [#]_.
302
346
 
303
347
* A dictionary. You can initialise a ConfigObj from a dictionary [#]_. The
304
348
  ``filename`` attribute of your ConfigObj will be ``None``. All keys must be
329
373
 
330
374
    If ``True`` (the default) then list values are possible. If ``False``, the
331
375
    values are not parsed for lists.
 
376
        
 
377
        If ``list_values = False`` then single line values are not quoted or
 
378
        unquoted when reading and writing.
332
379
 
333
 
    Altering this value after initial parsing has no effect.
 
380
    Changing this value affects whether single line values will be quoted or 
 
381
    not when writing.
334
382
 
335
383
* 'create_empty': ``False``
336
384
 
353
401
    default.
354
402
 
355
403
    You can set this attribute to change whether string interpolation is done
356
 
    when values are fetched. See the interpolation_ section for more details.
 
404
    when values are fetched. See the `String Interpolation`_ section for more details.
357
405
 
358
406
* 'configspec': ``None``
359
407
 
383
431
    non-string value [#]_ will raise a ``TypeError`` (no type conversion is
384
432
    done by validation).
385
433
 
386
 
* 'indent_type': ``' '``
 
434
* 'indent_type': ``'    '``
387
435
 
388
 
    Indentation is not significant; it can however be present in the output
389
 
    config. Allowable values are: ``''`` (no indentation), ``' '`` (indentation
390
 
    with spaces, fixed at four per level), or ``'\t'`` (indentation with tabs,
391
 
    one tab per level).
 
436
    Indentation is not significant; it can however be present in the input and
 
437
    output config. Any combination of tabs and spaces may be used: the string
 
438
    will be repeated for each level of indentation. Typical values are: ``''``
 
439
    (no indentation), ``'    '`` (indentation with four spaces, the default),
 
440
    ``'\t'`` (indentation with one tab).
392
441
 
393
442
    If this option is not specified, and the ConfigObj is initialised with a
394
443
    dictionary, the indentation used in the output is the default one, that is,
395
 
    spaces.
 
444
    four spaces.
396
445
 
397
446
    If this option is not specified, and the ConfigObj is initialised with a
398
447
    list of lines or a file, the indentation used in the first indented line is
402
451
    If this option *is* specified, the option value is used in the output
403
452
    config, overriding the type of indentation in the input config (if any).
404
453
 
 
454
* 'encoding': ``None``
 
455
 
 
456
    By default **ConfigObj** does not decode the file/strings you pass it into
 
457
    Unicode [#]_. If you want your config file as Unicode (keys and members)
 
458
    you need to provide an encoding to decode the file with. This encoding will
 
459
    also be used to encode the config file when writing.
 
460
    
 
461
    You can change the encoding attribute at any time.
 
462
    
 
463
    Any characters in your strings that can't be encoded with the specified
 
464
    encoding will raise a ``UnicodeEncodeError``.
 
465
    
 
466
    .. note::
 
467
    
 
468
        ``UTF16`` encoded files will automatically be detected and decoded,
 
469
        even if ``encoding`` is ``None``.
 
470
        
 
471
        This is because it is a 16-bit encoding, and ConfigObj will mangle it
 
472
        (split characters on byte boundaries) if it parses it without decoding.
 
473
 
 
474
* 'default_encoding': ``None``
 
475
 
 
476
    When using the ``write`` method, **ConfigObj** uses the ``encoding``
 
477
    attribute to encode the Unicode strings. If any members (or keys) have
 
478
    been set as byte strings instead of Unicode, these must first be decoded
 
479
    to Unicode before outputting in the specified encoding.
 
480
 
 
481
    ``default_encoding``, if specified, is the encoding used to decode byte
 
482
    strings in the **ConfigObj** before writing. If this is ``None``, then
 
483
    the Python default encoding (``sys.defaultencoding`` - usually ASCII) is
 
484
    used.
 
485
    
 
486
    For most Western European users, a value of ``latin-1`` is sensible.
 
487
    
 
488
    ``default_encoding`` is *only* used if an ``encoding`` is specified.
 
489
    
 
490
    Any characters in byte-strings that can't be decoded using the
 
491
    ``default_encoding`` will raise a ``UnicodeDecodeError``.
 
492
 
 
493
* 'unrepr': ``False``
 
494
 
 
495
    The ``unrepr`` option reads and writes files in a different mode. This
 
496
    allows you to store and retrieve the basic Python data-types using config
 
497
    files.
 
498
    
 
499
    This uses Python syntax for lists and quoting. See `unrepr mode`_ for the
 
500
    full details.
 
501
 
 
502
* 'write_empty_values': ``False`` 
 
503
 
 
504
    If ``write_empty_values`` is ``True``, empty strings are written as
 
505
    empty values. See `Empty Values`_ for more details.
 
506
 
405
507
Methods
406
508
-------
407
509
 
409
511
subclass of ``dict``, the builtin dictionary type. This means it also has
410
512
**all** the normal dictionary methods.
411
513
 
412
 
In addition, the *encode*, *decode*, *walk*, and *dict* methods of section may
413
 
be useful. The sections and subsections are also instances of ``Section``. Read
414
 
about Sections_ for details of all the methods.
 
514
In addition, the following `Section Methods`_ may be useful :
 
515
 
 
516
* *encode*
 
517
* *decode*
 
518
* *walk*
 
519
* *merge*
 
520
* *dict* 
 
521
* *as_bool*
 
522
* *as_float*
 
523
* *as_int*
 
524
 
 
525
Read about Sections_ for details of all the methods.
 
526
 
 
527
.. hint::
 
528
 
 
529
    The *merge* method of sections is a recursive update.
 
530
    
 
531
    You can use this to merge sections, or even whole ConfigObjs, into each
 
532
    other.
 
533
    
 
534
    You would typically use this to create a default ConfigObj and then merge
 
535
    in user settings. This way users only need to specify values that are
 
536
    different from the default.
 
537
    
415
538
 
416
539
The public methods available on ConfigObj are :
417
540
 
421
544
write
422
545
~~~~~
423
546
 
424
 
This method takes no arguments [#]_. It writes the current ConfigObj. What that
425
 
means depends on the ``filename`` attribute of the ConfigObj.
426
 
 
427
 
filename
428
 
    ConfigObj will write the configuration to file.
 
547
::
 
548
 
 
549
    write(file_object=None)
 
550
 
 
551
This method writes the current ConfigObj and takes a single, optional argument
 
552
[#]_.
 
553
 
 
554
If you pass in a file like object to the ``write`` method, the config file will
 
555
be written to this. (The only method of this object that is used is its
 
556
``write`` method, so a ``StringIO`` instance, or any other file like object
 
557
will work.)
 
558
 
 
559
Otherwise, the behaviour of this method depends on the ``filename`` attribute
 
560
of the ConfigObj.
 
561
 
 
562
``filename``
 
563
    ConfigObj will write the configuration to the file specified.
429
564
 
430
565
``None``
431
566
    ``write`` returns a list of lines. (Not ``'\n'`` terminated)
432
567
 
433
 
``StringIO``
434
 
    If ``filename`` is an object with a seek attribute, then the config file is
435
 
    written to that object.
436
 
 
437
568
First the 'initial_comment' is written, then the config file, followed by the
438
569
'final_comment'. Comment lines and inline comments are written with each
439
570
key/value.
441
572
validate
442
573
~~~~~~~~
443
574
 
 
575
::
 
576
 
 
577
    validate(validator, preserve_errors=False, copy=False)
 
578
 
444
579
.. raw:: html
445
580
 
446
581
    {+coloring}
458
593
 
459
594
    {-coloring}
460
595
 
 
596
The validate method uses the `validate 
 
597
<http://www.voidspace.org.uk/python/validate.html>`__ module to do the
 
598
validation.
 
599
    
461
600
This method validates the ConfigObj against the configspec. By doing type
462
601
conversion as well, it can abstract away the config file altogether and present
463
602
the config *data* to your application (in the types it expects it to be).
477
616
 
478
617
.. hint::
479
618
 
480
 
    If your ConfigObj is only comprised of basic data types, then you can use
481
 
    a function from the ConfigPersist.py_ module to auto-generate your
482
 
    configspec.
483
 
    
484
 
    See `ConfigObj for Data Persistence`_.
 
619
    The system of configspecs can seem confusing at first, but is actually
 
620
    quite simple and powerful. For a concrete example of how to use it, you may
 
621
    find this blog entry helpful :
 
622
    `Transforming Values with ConfigObj <http://www.voidspace.org.uk/python/weblog/arch_d7_2006_03_04.shtml#e257>`_.
 
623
 
 
624
    There is also a module to assist in auto-generating configspecs called
 
625
    ConfigPersist.py_. Its use is explained in `ConfigObj for Data Persistence`_.
 
626
 
 
627
The ``copy`` parameter fills in missing values from the configspec (default
 
628
values), *without* marking the values as defaults. It also causes comments to
 
629
be copied from the configspec into the config file. This allows you to use a
 
630
configspec to create default config files. (Normally default values aren't
 
631
written out by the ``write`` method.)
 
632
 
 
633
As of ConfigObj 4.3.0 you can also pass in a ConfigObj instance as your
 
634
configspec. This is especially useful if you need to specify the encoding of
 
635
your configspec file. When you read your configspec file, you *must* specify
 
636
``list_values=False``.
 
637
 
 
638
.. raw:: html
 
639
 
 
640
    {+coloring}
 
641
    from configobj import ConfigObj
 
642
    configspec = ConfigObj(configspecfilename, encoding='UTF8',
 
643
        list_values=False)
 
644
    config = ConfigObj(filename, configspec=configspec)
 
645
    {-coloring}
485
646
 
486
647
Return Value
487
648
############
488
649
 
489
 
The validate method either returns ``True`` (everything passed) or a dictionary 
490
 
of ``True``/``False`` representing pass/fail. The dictionary follows the 
491
 
structure of the ConfigObj
 
650
By default, the validate method either returns ``True`` (everything passed) 
 
651
or a dictionary of ``True``/``False`` representing pass/fail. The dictionary 
 
652
follows the structure of the ConfigObj.
492
653
 
493
654
If a whole section passes then it is replaced with the value ``True``. If a 
494
655
whole section fails, then it is replaced with the value ``False``.
496
657
If a value is missing, and there is no default in the check, then the check 
497
658
automatically fails.
498
659
 
 
660
The ``validate`` method takes an optional keyword argument ``preserve_errors``.
 
661
If you set this to ``True``, instead of getting ``False`` for failed checks you
 
662
get the actual error object from the **validate** module. This usually contains
 
663
useful information about why the check failed.
 
664
 
 
665
See the `flatten_errors`_ function for how to turn your results dictionary into
 
666
a useful list of error messages.
 
667
 
 
668
Even if ``preserve_errors`` is ``True``, missing keys or sections will still be
 
669
represented by a ``False`` in the results dictionary.
 
670
 
499
671
Mentioning Default Values
500
672
#########################
501
673
 
536
708
    ``None``. This is because setting a value to a non-string raises an error
537
709
    if stringify is unset.
538
710
 
 
711
The default value can be a list. See `List Values`_ for the way to do this.
 
712
 
 
713
Writing invalid default values is a *guaranteed* way of confusing your users.
 
714
Default values **must** pass the check.
 
715
 
539
716
Mentioning Repeated Sections
540
717
############################
541
718
 
554
731
 
555
732
See `Repeated Sections`_ for examples.
556
733
 
 
734
 
557
735
Mentioning SimpleVal
558
736
####################
559
737
 
575
753
 
576
754
    {-coloring}
577
755
 
 
756
 
 
757
Mentioning copy Mode
 
758
####################
 
759
 
 
760
As discussed in `Mentioning Default Values`_, you can use a configspec to
 
761
supply default values. These are marked in the ConfigObj instance as defaults,
 
762
and *not* written out by the ``write`` mode. This means that your users only
 
763
need to supply values that are different from the defaults.
 
764
 
 
765
This can be inconvenient if you *do* want to write out the default values,
 
766
for example to write out a default config file.
 
767
 
 
768
If you set ``copy=True`` when you call validate, then no values are marked as
 
769
defaults. In addition, all comments from the configspec are copied into
 
770
your ConfigObj instance. You can then call ``write`` to create your config
 
771
file.
 
772
    
 
773
There is a limitation with this. In order to allow `String Interpolation`_ to work
 
774
within configspecs, ``DEFAULT`` sections are not processed by
 
775
validation; even in copy mode.
 
776
 
578
777
Attributes
579
778
----------
580
779
 
586
785
* BOM
587
786
* initial_comment
588
787
* final_comment
 
788
* list_values
 
789
* encoding
 
790
* default_encoding
 
791
* unrepr
 
792
* write_empty_values
589
793
 
590
794
.. note::
591
795
 
598
802
* raise_errors
599
803
* create_empty
600
804
* file_error
601
 
* list_values
602
805
 
603
 
interpolate
604
 
~~~~~~~~~~~
 
806
interpolation
 
807
~~~~~~~~~~~~~
605
808
 
606
809
ConfigObj can perform string interpolation in a *similar* way to
607
 
``ConfigParser``. See the interpolation_ section for full details.
 
810
``ConfigParser``. See the `String Interpolation`_ section for full details.
608
811
 
609
 
If ``interpolate`` is set to ``False``, then interpolation is *not* done when
 
812
If ``interpolation`` is set to ``False``, then interpolation is *not* done when
610
813
you fetch values.
611
814
 
612
815
stringify
623
826
~~~
624
827
 
625
828
If the initial config file *started* with the UTF8 Unicode signature (known
626
 
slightly incorrectly as the {acro;BOM;Byte Order Mark}), then this value will
627
 
be set to the UTF8 BOM. Otherwise it is ``None``.
628
 
 
629
 
If it is set, then it is  written out by the ``write`` method.
 
829
slightly incorrectly as the {acro;BOM;Byte Order Mark}), or the UTF16 BOM, then
 
830
this attribute is set to ``True``. Otherwise it is ``False``.
 
831
 
 
832
If it is set to ``True`` when ``write`` is called then, if ``encoding`` is set
 
833
to ``None`` *or* to ``utf_8`` (and variants) a UTF BOM will be written.
 
834
 
 
835
For UTF16 encodings, a BOM is *always* written.
630
836
 
631
837
initial_comment
632
838
~~~~~~~~~~~~~~~
649
855
The ``write`` method puts these lines after it finishes writing out the
650
856
members.
651
857
 
 
858
list_values
 
859
~~~~~~~~~~~
 
860
 
 
861
This attribute is ``True`` or ``False``. If set to ``False`` then values are
 
862
not parsed for list values. In addition single line values are not unquoted.
 
863
 
 
864
This allows you to do your own parsing of values. It exists primarily to
 
865
support the reading of the configspec_ - but has other use cases.
 
866
 
 
867
For example you could use the ``LineParser`` from the
 
868
`listquote module <http://www.voidspace.org.uk/python/listquote.html#lineparser>`_ 
 
869
to read values for nested lists.
 
870
 
 
871
Single line values aren't quoted when writing - but multiline values are
 
872
handled as normal.
 
873
 
 
874
.. caution::
 
875
 
 
876
    Because values aren't quoted, leading or trailing whitespace can be
 
877
        lost.
 
878
 
 
879
    This behaviour was changed in version 4.0.1.
 
880
        
 
881
        Prior to this, single line values might have been quoted; even with
 
882
        ``list_values=False``. This means that files written by **ConfigObj**
 
883
        *could* now be incompatible - and need the quotes removing by hand.
 
884
 
 
885
encoding
 
886
~~~~~~~~
 
887
 
 
888
This is the encoding used to encode the output, when you call ``write``. It
 
889
must be a valid encoding `recognised by Python <http://docs.python.org/lib/standard-encodings.html>`_.
 
890
 
 
891
If this value is ``None`` then no encoding is done when ``write`` is called.
 
892
 
 
893
 
 
894
default_encoding
 
895
~~~~~~~~~~~~~~~~
 
896
 
 
897
If encoding is set, any byte-strings in your ConfigObj instance (keys or
 
898
members) will first be decoded to Unicode using the encoding specified by the
 
899
``default_encoding`` attribute. This ensures that the output is in the encoding
 
900
specified.
 
901
 
 
902
If this value is ``None`` then ``sys.defaultencoding`` is used instead.
 
903
 
 
904
unrepr
 
905
~~~~~~
 
906
 
 
907
Another boolean value. If this is set, then ``repr(value)`` is used to write
 
908
values. This writes values in a slightly different way to the normal ConfigObj
 
909
file syntax.
 
910
 
 
911
This preserves basic Python data-types when read back in. See `unrepr mode`_
 
912
for more details.
 
913
 
 
914
write_empty_values
 
915
~~~~~~~~~~~~~~~~~~
 
916
 
 
917
Also boolean. If set, values that are an empty string (``''``) are written as
 
918
empty values. See `Empty Values`_ for more details.
 
919
 
 
920
 
652
921
The Config File Format
653
922
======================
654
923
 
765
1034
 
766
1035
    {+coloring}
767
1036
 
768
 
    {
 
1037
    ConfigObj({
769
1038
        'keyword1': 'value1',
770
1039
        'keyword2': 'value2',
771
1040
        'section 1': {
788
1057
                'keyword2': 'value2',
789
1058
            },
790
1059
        },
791
 
    }
 
1060
    })
792
1061
 
793
1062
    {-coloring}
794
1063
 
795
1064
Sections are ordered: note how the structure of the resulting ConfigObj is in
796
1065
the same order as the original file.
797
1066
 
 
1067
.. note::
 
1068
 
 
1069
    In ConfigObj 4.3.0 *empty values* became valid syntax. They are read as the
 
1070
    empty string. There is also an option/attribute (``write_empty_values``) to
 
1071
    allow the writing of these.
 
1072
    
 
1073
    This is mainly to support 'legacy' config files, written from other
 
1074
    applications. This is documented under `Empty Values`_.
 
1075
    
 
1076
    `unrepr mode`_ introduces *another* syntax variation, used for storing
 
1077
    basic Python datatypes in config files. {sm;:-)}
 
1078
 
 
1079
 
798
1080
Sections
799
1081
========
800
1082
 
943
1225
Section Methods
944
1226
---------------
945
1227
 
946
 
* 'dict'
 
1228
* **dict**
947
1229
 
948
1230
    This method takes no arguments. It returns a deep copy of the section as a
949
1231
    dictionary. All subsections will also be dictionaries, and list values will
950
1232
    be copies, rather than references to the original [#]_.
951
1233
 
952
 
* rename
 
1234
* **rename**
953
1235
 
954
1236
    ``rename(oldkey, newkey)``
955
1237
 
958
1240
    It is mainly implemented for the ``encode`` and ``decode`` methods, which
959
1241
    provide some Unicode support.
960
1242
 
961
 
* walk
 
1243
* **merge**
 
1244
 
 
1245
    ``merge(indict)``
 
1246
    
 
1247
    This method is a *recursive update* method. It allows you to merge two
 
1248
    config files together.
 
1249
    
 
1250
    You would typically use this to create a default ConfigObj and then merge
 
1251
    in user settings. This way users only need to specify values that are
 
1252
    different from the default.
 
1253
    
 
1254
    For example :
 
1255
    
 
1256
    .. raw:: html
 
1257
    
 
1258
        {+coloring}
 
1259
        
 
1260
        # def_cfg contains your default config settings
 
1261
        # user_cfg contains the user settings
 
1262
        cfg = ConfigObj(def_cfg)
 
1263
        usr = ConfigObj(user_cfg)
 
1264
        #
 
1265
        cfg.merge(usr)
 
1266
        
 
1267
        """
 
1268
        cfg now contains a combination of the default settings and the user
 
1269
        settings.
 
1270
        
 
1271
        The user settings will have overwritten any of the default ones.
 
1272
        """
 
1273
    
 
1274
        {-coloring}
 
1275
    
 
1276
* **walk**
962
1277
 
963
1278
    This method can be used to transform values and names. See `walking a
964
1279
    section`_ for examples and explanation.
965
1280
 
966
 
* decode
 
1281
* **decode**
967
1282
 
968
1283
    ``decode(encoding)``
969
1284
 
970
1285
    This method decodes names and values into Unicode objects, using the
971
1286
    supplied encoding.
972
1287
 
973
 
    Because of the way ConfigObj reads files, config files should be in an
974
 
    ASCII compatible encoding. See encodings_ for more details.
975
 
 
976
 
* encode
 
1288
* **encode**
977
1289
 
978
1290
    ``encode(encoding)``
979
1291
 
981
1293
 
982
1294
    It encodes names and values using the supplied encoding. If any of your
983
1295
    names/values are strings rather than Unicode, Python will have to do an
984
 
    implicit decode first.
985
 
 
986
 
    See encodings_ for more details.
987
 
 
 
1296
    implicit decode first. (This method uses ``sys.defaultencoding`` for
 
1297
    implicit decodes.)
 
1298
 
 
1299
* **as_bool**
 
1300
 
 
1301
    ``as_bool(key)``
 
1302
    
 
1303
    Returns ``True`` if the key contains a string that represents ``True``, or
 
1304
    is the ``True`` object.
 
1305
    
 
1306
    Returns ``False`` if the key contains a string that represents ``False``, 
 
1307
    or is the ``False`` object. 
 
1308
 
 
1309
    Raises a ``ValueError`` if the key contains anything else.
 
1310
    
 
1311
    Strings that represent ``True`` are (not case sensitive) : ::
 
1312
    
 
1313
        true, yes, on, 1
 
1314
        
 
1315
    Strings that represent ``False`` are : ::
 
1316
    
 
1317
        false, no, off, 0
 
1318
    
 
1319
    .. note::
 
1320
    
 
1321
        In ConfigObj 4.1.0, this method was called ``istrue``. That method is
 
1322
        now deprecated and will issue a warning when used. It will go away
 
1323
        in a future release.
 
1324
        
 
1325
* **as_int**
 
1326
 
 
1327
    ``as_int(key)``
 
1328
    
 
1329
    This returns the value contained in the specified key as an integer.
 
1330
    
 
1331
    It raises a ``ValueError`` if the conversion can't be done.
 
1332
 
 
1333
* **as_float**
 
1334
 
 
1335
    ``as_float(key)``
 
1336
    
 
1337
    This returns the value contained in the specified key as a float.
 
1338
    
 
1339
    It raises a ``ValueError`` if the conversion can't be done.
 
1340
    
988
1341
Walking a Section
989
1342
-----------------
990
1343
 
1028
1381
If you are using the return value from ``walk`` *and* ``call_on_sections``,
1029
1382
note that walk discards the return value when it calls your function.
1030
1383
 
 
1384
.. caution::
 
1385
 
 
1386
    You can use ``walk`` to transform the names of members of a section
 
1387
    but you mustn't add or delete members.
 
1388
 
 
1389
 
1031
1390
Examples
1032
1391
--------
1033
1392
 
1040
1399
 
1041
1400
You can use this for transforming all values in your ConfigObj. For example
1042
1401
you might like the nested lists from ConfigObj 3. This was provided by the
1043
 
listquote_ module [#]_. You could switch off the parsing for list values
 
1402
listquote_ module. You could switch off the parsing for list values
1044
1403
(``list_values=False``) and use listquote to parse every value.
1045
1404
 
1046
1405
Another thing you might want to do is use the Python escape codes in your
1116
1475
 
1117
1476
    {-coloring}
1118
1477
 
 
1478
Here's a simple example of using ``walk`` to transform names and values. One
 
1479
usecase of this would be to create a *standard* config file with placeholders
 
1480
for section and keynames. You can then use walk to create new config files
 
1481
and change values and member names :
 
1482
 
 
1483
.. raw:: html
 
1484
 
 
1485
    {+coloring}
 
1486
 
 
1487
    # We use 'XXXX' as a placeholder
 
1488
    config = '''
 
1489
    XXXXkey1 = XXXXvalue1
 
1490
    XXXXkey2 = XXXXvalue2
 
1491
    XXXXkey3 = XXXXvalue3
 
1492
    [XXXXsection1]
 
1493
    XXXXkey1 = XXXXvalue1
 
1494
    XXXXkey2 = XXXXvalue2
 
1495
    XXXXkey3 = XXXXvalue3
 
1496
    [XXXXsection2]
 
1497
    XXXXkey1 = XXXXvalue1
 
1498
    XXXXkey2 = XXXXvalue2
 
1499
    XXXXkey3 = XXXXvalue3
 
1500
        [[XXXXsection1]]
 
1501
        XXXXkey1 = XXXXvalue1
 
1502
        XXXXkey2 = XXXXvalue2
 
1503
        XXXXkey3 = XXXXvalue3
 
1504
    '''.splitlines()
 
1505
    cfg = ConfigObj(config)
 
1506
    #
 
1507
    def transform(section, key):
 
1508
        val = section[key]
 
1509
        newkey = key.replace('XXXX', 'CLIENT1')
 
1510
        section.rename(key, newkey)
 
1511
        if isinstance(val, (tuple, list, dict)):
 
1512
            pass
 
1513
        else:
 
1514
            val = val.replace('XXXX', 'CLIENT1')
 
1515
            section[newkey] = val
 
1516
    #
 
1517
    cfg.walk(transform, call_on_sections=True)
 
1518
    print cfg
 
1519
    ConfigObj({'CLIENT1key1': 'CLIENT1value1', 'CLIENT1key2': 'CLIENT1value2', 
 
1520
    'CLIENT1key3': 'CLIENT1value3', 
 
1521
    'CLIENT1section1': {'CLIENT1key1': 'CLIENT1value1', 
 
1522
        'CLIENT1key2': 'CLIENT1value2', 'CLIENT1key3': 'CLIENT1value3'}, 
 
1523
    'CLIENT1section2': {'CLIENT1key1': 'CLIENT1value1', 
 
1524
        'CLIENT1key2': 'CLIENT1value2', 'CLIENT1key3': 'CLIENT1value3', 
 
1525
        'CLIENT1section1': {'CLIENT1key1': 'CLIENT1value1', 
 
1526
            'CLIENT1key2': 'CLIENT1value2', 'CLIENT1key3': 'CLIENT1value3'}}})
 
1527
            
 
1528
    {-coloring}
 
1529
 
 
1530
 
1119
1531
Exceptions
1120
1532
==========
1121
1533
 
1127
1539
    raised.
1128
1540
 
1129
1541
2) If you try to set a non-string key, or a non string value when
1130
 
    ``stringify=False`, a ``TypeError`` will be raised.
 
1542
    ``stringify=False``, a ``TypeError`` will be raised.
1131
1543
 
1132
1544
3) A badly built config file will cause parsing errors.
1133
1545
 
1140
1552
    (in a configspec), a ``RepeatSectionError`` will be raised.
1141
1553
 
1142
1554
Number 5 (which is actually two different types of exceptions) is documented
1143
 
    in interpolation_.
 
1555
    in `String Interpolation`_.
1144
1556
 
1145
1557
Number 6 is explained in the validation_ section.
1146
1558
 
1169
1581
 
1170
1582
* ``ConfigspecError``
1171
1583
 
1172
 
    An error occured whilst parsing a configspec.
 
1584
    An error occurred whilst parsing a configspec.
 
1585
 
 
1586
* ``UnreprError``
 
1587
 
 
1588
    An error occurred when parsing a value in `unrepr mode`_.
1173
1589
 
1174
1590
When parsing a configspec, ConfigObj will stop on the first error it
1175
1591
encounters.  It will raise a ``ConfigspecError``. This will have an ``error``
1176
1592
attribute, which is the actual error that was raised.
1177
1593
 
1178
 
Behavior when parsing a config file depends on the option ``raise_errors``.
 
1594
Behaviour when parsing a config file depends on the option ``raise_errors``.
1179
1595
If ConfigObj encounters an error while parsing a config file:
1180
1596
 
1181
1597
    If ``raise_errors=True`` then ConfigObj will raise the appropriate error
1184
1600
    If ``raise_errors=False`` (the default) then parsing will continue to the
1185
1601
    end and *all* errors will be collected.
1186
1602
 
1187
 
In the second case a ``ConfigObjError`` is raised after parsing has stopped.
1188
 
The error raised has a ``config`` attribute, which is the parts of the
1189
 
ConfigObj that parsed successfully. It also has an attribute ``errors``, which
1190
 
is a list of *all* the errors raised. Each entry in the list is an instance of
1191
 
the appropriate error type. Each one has the following attributes (useful for
1192
 
delivering a sensible error message to your user) :
 
1603
If ``raise_errors`` is False and multiple errors are found a ``ConfigObjError``
 
1604
is raised. The error raised has a ``config`` attribute, which is the parts of
 
1605
the ConfigObj that parsed successfully. It also has an attribute ``errors``,
 
1606
which is a list of *all* the errors raised. Each entry in the list is an
 
1607
instance of the appropriate error type. Each one has the following attributes
 
1608
(useful for delivering a sensible error message to your user) :
1193
1609
 
1194
1610
* ``line``: the original line that caused the error.
1195
1611
 
1197
1613
 
1198
1614
* ``message``: the error message that accompanied the error.
1199
1615
 
 
1616
If only one error is found, then that error is re-raised. The error still has
 
1617
the ``config`` and ``errors`` attributes. This means that your error handling
 
1618
code can be the same whether one error is raised in parsing , or several.
 
1619
 
 
1620
It also means that in the most common case (a single error) a useful error
 
1621
message will be raised.
 
1622
 
1200
1623
.. note::
1201
1624
 
1202
1625
    One wrongly written line could break the basic structure of your config
1204
1627
    list of all the lines that caused errors may not be as useful as it sounds.
1205
1628
    {sm;:-(}.
1206
1629
 
 
1630
 
1207
1631
Validation
1208
1632
==========
1209
1633
 
 
1634
.. hint::
 
1635
 
 
1636
    The system of configspecs can seem confusing at first, but is actually
 
1637
    quite simple and powerful. For a concrete example of how to use it, you may
 
1638
    find this blog entry helpful :
 
1639
    `Transforming Values with ConfigObj <http://www.voidspace.org.uk/python/weblog/arch_d7_2006_03_04.shtml#e257>`_.
 
1640
 
 
1641
    There is also a module to assist in auto-generating configspecs called
 
1642
    ConfigPersist.py_. Its use is explained in `ConfigObj for Data Persistence`_.
 
1643
 
1210
1644
Validation is done through a combination of the configspec_ and a ``Validator``
1211
1645
object. For this you need *validate.py* [#]_. See downloading_ if you don't
1212
1646
have a copy.
1262
1696
For full details on writing configspecs, please refer to the `validate.py
1263
1697
documentation`_.
1264
1698
 
 
1699
.. important::
 
1700
 
 
1701
    Your configspec is read by ConfigObj in the same way as a config file.
 
1702
    
 
1703
    That means you can do interpolation *within* your configspec.
 
1704
    
 
1705
    In order to allow this, checks in the 'DEFAULT' section (of the root level
 
1706
    of your configspec) are *not* used.
 
1707
 
 
1708
If you need to specify the encoding of your configspec, then you can pass in a
 
1709
ConfigObj instance as your configspec. When you read your configspec file, you
 
1710
*must* specify ``list_values=False``.
 
1711
 
 
1712
.. raw:: html
 
1713
 
 
1714
    {+coloring}
 
1715
    from configobj import ConfigObj
 
1716
    configspec = ConfigObj(configspecfilename, encoding='UTF8',
 
1717
        list_values=False)
 
1718
    config = ConfigObj(filename, configspec=configspec)
 
1719
    {-coloring}
 
1720
 
1265
1721
.. _validate.py documentation: http://www.voidspace.org.uk/python/validate.html
1266
1722
 
1267
1723
Type Conversion
1305
1761
 
1306
1762
    Note that ``default=None`` is case sensitive.
1307
1763
 
 
1764
 
 
1765
List Values
 
1766
~~~~~~~~~~~
 
1767
 
 
1768
It's possible that you will want to specify a list as a default value. To avoid
 
1769
confusing syntax with commas and quotes you use a list constructor to specify 
 
1770
that keyword arguments are lists. This includes the ``default`` value. This 
 
1771
makes checks look something like : ::
 
1772
 
 
1773
    checkname(default=list('val1', 'val2', 'val3'))
 
1774
 
 
1775
This works with all keyword arguments, but is most useful for default values.
 
1776
 
 
1777
 
1308
1778
Repeated Sections
1309
1779
-----------------
1310
1780
 
1341
1811
sub-sections. Defaults work in the normal way in repeated sections.
1342
1812
 
1343
1813
 
 
1814
Copy Mode
 
1815
---------
 
1816
 
 
1817
Because you can specify default values in your configspec, you can use
 
1818
ConfigObj to write out default config files for your application.
 
1819
 
 
1820
However, normally values supplied from a default in a configspec are *not*
 
1821
written out by the ``write`` method.
 
1822
 
 
1823
To do this, you need to specify ``copy=True`` when you call validate. As well
 
1824
as not marking values as default, all the comments in the configspec file
 
1825
will be copied into your ConfigObj instance.
 
1826
 
 
1827
.. raw:: html
 
1828
 
 
1829
    {+coloring}
 
1830
    from configobj import ConfigObj
 
1831
    from validate import Validator
 
1832
    vdt = Validator()
 
1833
    config = ConfigObj(configspec='default.ini')
 
1834
    config.filename = 'new_default.ini'
 
1835
    config.validate(vdt, copy=True)
 
1836
    config.write()
 
1837
    {-coloring}
 
1838
 
1344
1839
Validation and Interpolation
1345
1840
----------------------------
1346
1841
 
1404
1899
 
1405
1900
    {-coloring}
1406
1901
 
1407
 
Interpolation
1408
 
=============
 
1902
 
 
1903
Empty values
 
1904
============
 
1905
 
 
1906
Many config files from other applications allow empty values. As of version
 
1907
4.3.0, ConfigObj will read these as an empty string.
 
1908
 
 
1909
A new option/attribute has been added (``write_empty_values``) to allow
 
1910
ConfigObj to write empty strings as empty values.
 
1911
 
 
1912
.. raw:: html
 
1913
 
 
1914
    {+coloring}
 
1915
    from configobj import ConfigObj
 
1916
    cfg = '''
 
1917
        key =
 
1918
        key2 = # a comment
 
1919
    '''.splitlines()
 
1920
    config = ConfigObj(cfg)
 
1921
    print config
 
1922
    ConfigObj({'key': '', 'key2': ''})
 
1923
    
 
1924
    config.write_empty_values = True
 
1925
    for line in config.write():
 
1926
        print line
 
1927
    
 
1928
    key = 
 
1929
    key2 =     # a comment
 
1930
    {-coloring}
 
1931
 
 
1932
unrepr mode
 
1933
===========
 
1934
 
 
1935
The ``unrepr`` option allows you to store and retrieve the basic Python
 
1936
data-types using config files. It has to use a slightly different syntax to
 
1937
normal ConfigObj files. Unsurprisingly it uses Python syntax.
 
1938
 
 
1939
This means that lists are different (they are surrounded by square brackets),
 
1940
and strings *must* be quoted.
 
1941
 
 
1942
The types that ``unrepr`` can work with are :
 
1943
 
 
1944
    | strings, lists tuples
 
1945
    | None, True, False
 
1946
    | dictionaries, integers, floats
 
1947
    | longs and complex numbers
 
1948
    
 
1949
You can't store classes, types or instances.
 
1950
 
 
1951
``unrepr`` uses ``repr(object)`` to write out values, so it currently *doesn't*
 
1952
check that you are writing valid objects. If you attempt to read an unsupported
 
1953
value, ConfigObj will raise a ``configobj.UnknownType`` exception.
 
1954
 
 
1955
Values that are triple quoted cased. The triple quotes are removed *before*
 
1956
converting. This means that you can use triple quotes to write dictionaries
 
1957
over several lines in your config files. They won't be written like this
 
1958
though.
 
1959
 
 
1960
If you are writing config files by hand, for use with ``unrepr``, you should
 
1961
be aware of the following differences from normal ConfigObj syntax :
 
1962
 
 
1963
    | List : ``['A List', 'With', 'Strings']``
 
1964
    | Strings : ``"Must be quoted."``
 
1965
    | Backslash : ``"The backslash must be escaped \\"``
 
1966
 
 
1967
These all follow normal Python syntax.
 
1968
 
 
1969
In unrepr mode *inline comments* are not saved. This is because lines are
 
1970
parsed using the `compiler package <http://docs.python.org/lib/compiler.html>`_
 
1971
which discards comments.
 
1972
 
 
1973
String Interpolation
 
1974
====================
1409
1975
 
1410
1976
ConfigObj allows string interpolation *similar* to the way ``ConfigParser``
1411
 
 
1412
 
You specify a value to be substituted by including ``%(name)s`` in the value.
1413
 
 
1414
 
Interpolation checks first the 'DEFAULT' sub-section of the current section to
1415
 
see if ``name`` is the key to a value. ('name' is case sensitive).
1416
 
 
1417
 
If it doesn't find it, next it checks the 'DEFAULT' section of the parent
1418
 
section, last it checks the 'DEFAULT' section of the main section.
1419
 
 
1420
 
If the value specified isn't found then a ``MissingInterpolationOption`` error
1421
 
is raised (a subclass of ``ConfigObjError``).
 
1977
or ``string.Template`` work. The value of the ``interpolation`` attribute
 
1978
determines which style of interpolation you want to use. Valid values are
 
1979
"ConfigParser" or "Template" (case-insensitive, so "configparser" and
 
1980
"template" will also work). For backwards compatibility reasons, the value
 
1981
``True`` is also a valid value for the ``interpolation`` attribute, and
 
1982
will select ``ConfigParser``-style interpolation. At some undetermined point
 
1983
in the future, that default *may* change to ``Template``-style interpolation.
 
1984
 
 
1985
For ``ConfigParser``-style interpolation, you specify a value to be
 
1986
substituted by including ``%(name)s`` in the value.
 
1987
 
 
1988
For ``Template``-style interpolation, you specify a value to be substituted
 
1989
by including ``${cl}name{cr}`` in the value. Alternately, if 'name' is a valid
 
1990
Python identifier (i.e., is composed of nothing but alphanumeric characters,
 
1991
plus the underscore character), then the braces are optional and the value
 
1992
can be written as ``$name``.
 
1993
 
 
1994
Note that ``ConfigParser``-style interpolation and ``Template``-style
 
1995
interpolation are mutually exclusive; you cannot have a configuration file
 
1996
that's a mix of one or the other. Pick one and stick to it. ``Template``-style
 
1997
interpolation is simpler to read and write by hand, and is recommended if
 
1998
you don't have a particular reason to use ``ConfigParser``-style.
 
1999
 
 
2000
Interpolation checks first the current section to see if ``name`` is the key
 
2001
to a value. ('name' is case sensitive).
 
2002
 
 
2003
If it doesn't find it, next it checks the 'DEFAULT' sub-section of the current
 
2004
section.
 
2005
 
 
2006
If it still doesn't find it, it moves on to check the parent section and the
 
2007
parent section's 'DEFAULT' subsection, and so on all the way up to the main
 
2008
section.
 
2009
 
 
2010
If the value specified isn't found in any of these locations, then a
 
2011
``MissingInterpolationOption`` error is raised (a subclass of
 
2012
``ConfigObjError``).
1422
2013
 
1423
2014
If it is found then the returned value is also checked for substitutions. This
1424
2015
allows you to make up compound values (for example directory paths) that use
1425
2016
more than one default value. It also means it's possible to create circular
1426
 
references. If after ten replacements there are still values to substitute, an
1427
 
``InterpolationDepthError`` is raised.
 
2017
references. If there are any circular references which would cause an infinite
 
2018
interpolation loop, an ``InterpolationLoopError`` is raised.
1428
2019
 
1429
2020
Both of these errors are subclasses of ``InterpolationError``, which is a
1430
2021
subclass of ``ConfigObjError``.
1434
2025
See `Validation and Interpolation`_. (This can only happen if validation
1435
2026
has to *change* the value).
1436
2027
 
 
2028
 
1437
2029
Comments
1438
2030
========
1439
2031
 
1459
2051
 
1460
2052
These comments are all written back out by the ``write`` method.
1461
2053
 
1462
 
Encodings
1463
 
=========
1464
 
 
1465
 
ConfigObj 4 is designed to work with ASCII compatible encodings [#]_. If you
1466
 
need support for other character sets, then I suggest you use the UTF8
1467
 
encoding for your config files.
1468
 
 
1469
 
By default ConfigObj leaves keys/members as encoded byte strings (ordinary
1470
 
strings). If you want to access the config file members as Unicode objects
1471
 
rather than strings, you can use the ``decode`` method. This takes an encoding
1472
 
as its argument and decodes all members and keys into Unicode. It will only
1473
 
work if *all* members are byte strings (or lists of strings) , so you should do
1474
 
it before calling ``validate``.
1475
 
 
1476
 
If you want to turn the Unicode strings back into byte strings, you can call
1477
 
the ``encode`` method. This also takes an encoding as its argument and assumes
1478
 
*all* keys/members are Unicode.
1479
 
 
1480
 
If you start working with Unicode strings, you may find you get
1481
 
``UnicodeDecodeError`` or ``UnicodeEncodeError`` in unexpected places. This is
1482
 
because you have forced Python to do an *implicit* encode or decode.
1483
 
 
1484
 
Implicit decodes (and encodes) use the encoding returned by
1485
 
``sys.getdefaultencoding()``. This is *usually* ASCII. This means that if you
1486
 
have any non-ASCII characters, Python doesn't know how to treat them and will
1487
 
raise an error.
1488
 
 
1489
 
This happens if you add a byte string to a Unicode string, compare a byte
1490
 
string to a Unicode string, print a Unicode string, or write it to a file. If
1491
 
you work with Unicode, you should do the appropriate encode or decode first.
 
2054
 
 
2055
flatten_errors
 
2056
==============
 
2057
 
 
2058
::
 
2059
 
 
2060
    flatten_errors(cfg, res)
 
2061
 
 
2062
Validation_ is a powerful way of checking that the values supplied by the user
 
2063
make sense.
 
2064
 
 
2065
The validate_ method returns a results dictionary that represents pass or fail
 
2066
for each value. This doesn't give you any information about *why* the check
 
2067
failed.
 
2068
 
 
2069
``flatten_errors`` is an example function that turns a results dictionary into
 
2070
a flat list, that only contains values that *failed*.
 
2071
 
 
2072
``cfg`` is the ConfigObj instance being checked, ``res`` is the results
 
2073
dictionary returned by ``validate``.
 
2074
 
 
2075
It returns a list of keys that failed. Each member of the list is a tuple : ::
 
2076
 
 
2077
    ([list of sections...], key, result)
 
2078
 
 
2079
If ``validate`` was called with ``preserve_errors=False`` (the default)
 
2080
then ``result`` will always be ``False``.
 
2081
 
 
2082
*list of sections* is a flattened list of sections that the key was found
 
2083
in.
 
2084
 
 
2085
If the section was missing then key will be ``None``.
 
2086
 
 
2087
If the value (or section) was missing then ``result`` will be ``False``.
 
2088
 
 
2089
If ``validate`` was called with ``preserve_errors=True`` and a value
 
2090
was present, but failed the check, then ``result`` will be the exception
 
2091
object returned. You can use this as a string that describes the failure.
 
2092
 
 
2093
For example :
 
2094
 
 
2095
    *The value "3" is of the wrong type*.
 
2096
 
 
2097
 
 
2098
Example Usage
 
2099
-------------
 
2100
 
 
2101
The output from ``flatten_errors`` is a list of tuples.
 
2102
 
 
2103
Here is an example of how you could present this information to the user.
 
2104
 
 
2105
.. raw:: html
 
2106
 
 
2107
    {+coloring}
 
2108
    
 
2109
    vtor = validate.Validator()
 
2110
    # ini is your config file - cs is the configspec
 
2111
    cfg = ConfigObj(ini, configspec=cs)
 
2112
    res = cfg.validate(vtor, preserve_errors=True)
 
2113
    for entry in flatten_errors(cfg, res):
 
2114
        # each entry is a tuple
 
2115
        section_list, key, error = entry
 
2116
        if key is not None:
 
2117
           section_list.append(key)
 
2118
        else:
 
2119
            section_list.append('[missing section]')
 
2120
        section_string = ', '.join(section_list)
 
2121
        if error == False:
 
2122
            error = 'Missing value or section.'
 
2123
        print section_string, ' = ', error
 
2124
 
 
2125
    {-coloring}
1492
2126
 
1493
2127
Backwards Compatibility
1494
2128
=======================
1546
2180
 
1547
2181
The ``newline``, ``force_return``, and ``default`` options have gone.
1548
2182
 
1549
 
The ``encoding`` and ``backup_encoding`` methods have gone, replaced with the
1550
 
``encode`` and ``decode`` methods.
1551
 
 
1552
2183
``fileerror`` and ``createempty`` options have become ``file_error`` and
1553
2184
``create_empty``.
1554
2185
 
1556
2187
and which should be present) have gone. The configspec is no longer used to
1557
2188
specify order for the ``write`` method.
1558
2189
 
1559
 
Exceeding the maximum depth of recursion in string interpolation now raises an
1560
 
error ``InterpolationDepthError``.
 
2190
Infinite loops in string interpolation are now detected and raise an error
 
2191
``InterpolationLoopError``.
1561
2192
 
1562
2193
Specifying a value for interpolation which doesn't exist now raises a
1563
2194
``MissingInterpolationOption`` error (instead of merely being ignored).
1580
2211
.. _ConfigObj 3.3.1: http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=configobj3.zip
1581
2212
.. _ConfigObj 3 Docs: http://www.voidspace.org.uk/python/configobj3.html
1582
2213
 
 
2214
 
1583
2215
CREDITS
1584
2216
=======
1585
2217
 
1593
2225
 
1594
2226
Thanks to others for input and bugfixes.
1595
2227
 
 
2228
 
1596
2229
LICENSE
1597
2230
=======
1598
2231
 
1602
2235
Of course if it does, let us know and we'll fix the problem so it doesn't
1603
2236
happen to anyone else {sm;:-)}. ::
1604
2237
 
1605
 
    Copyright (c) 2004 & 2005, Michael Foord & Nicola Larosa
 
2238
    Copyright (c) 2004 - 2006, Michael Foord & Nicola Larosa
1606
2239
    All rights reserved.
1607
2240
 
1608
2241
    Redistribution and use in source and binary forms, with or without
1636
2269
 
1637
2270
You should also be able to find a copy of this license at : `BSD License`_
1638
2271
 
1639
 
.. _BSD License: http://www.voidspace.org.uk/documents/BSD-LICENSE.txt
 
2272
.. _BSD License: http://www.voidspace.org.uk/python/license.shtml
 
2273
 
1640
2274
 
1641
2275
TODO
1642
2276
====
1643
2277
 
1644
 
Fix any bugs (and resolvable issues).
1645
 
 
1646
 
Do an example for the 'walk' which removes uniform indentation in multiline
1647
 
values.
1648
 
 
1649
 
When initialising a section from a ConfigObj *or* an ``OrderedDictionary``
1650
 
we could preserve ordering.
1651
 
 
1652
 
Add an *odict* method which returns an `OrderedDictionary``.
 
2278
Better support for configuration from multiple files, including tracking
 
2279
*where* the original file came from and writing changes to the correct
 
2280
file.
 
2281
 
 
2282
Make ``newline`` an option (as well as an attribute) ?
 
2283
 
 
2284
``UTF16`` encoded files, when returned as a list of lines, will have the
 
2285
BOM at the start of every line. Should this be removed from all but the
 
2286
first line ?
 
2287
 
 
2288
Option to set warning type for unicode decode ? (Defaults to strict).
 
2289
 
 
2290
A method to optionally remove uniform indentation from multiline values.
 
2291
(do as an example of using ``walk`` - along with string-escape)
 
2292
 
 
2293
Should the results dictionary from validate be an ordered dictionary if
 
2294
`odict <http://www.voidspace.org.uk/python/odict.html>`_ is available ?
 
2295
 
 
2296
Implement some of the sequence methods (which include slicing) from the
 
2297
newer ``odict`` ?
 
2298
 
 
2299
Preserve line numbers of values (and possibly the original text of each value).
 
2300
 
1653
2301
 
1654
2302
ISSUES
1655
2303
======
1656
2304
 
1657
2305
.. note::
1658
2306
 
1659
 
    Please file any bug reports to `Michael Foord`_ or the ConfigObj
 
2307
    Please file any bug reports to `Michael Foord`_ or the **ConfigObj**
1660
2308
    `Mailing List`_.
1661
2309
 
1662
 
You can't have a keyword with the same name as a section (in the same section).
1663
 
They are both dictionary keys, so they would overlap.
1664
 
 
1665
 
Interpolation checks first the 'DEFAULT' sub-section of the current section,
1666
 
next it checks the 'DEFAULT' section of the parent section, last it checks the
1667
 
'DEFAULT' section of the main section.
 
2310
There is currently no way to specify the encoding of a configspec file.
 
2311
 
 
2312
When using ``copy`` mode for validation, it won't copy ``DEFAULT``
 
2313
sections. This is so that you *can* use interpolation in configspec
 
2314
files.
 
2315
 
 
2316
``validate`` doesn't report *extra* values or sections.
 
2317
 
 
2318
You can't have a keyword with the same name as a section (in the same
 
2319
section). They are both dictionary keys - so they would overlap.
 
2320
 
 
2321
ConfigObj doesn't quote and unquote values if ``list_values=False``.
 
2322
This means that leading or trailing whitespace in values will be lost when
 
2323
writing. (Unless you manually quote).
 
2324
 
 
2325
Interpolation checks first the current section, then the 'DEFAULT' subsection
 
2326
of the current section, before moving on to the current section's parent and
 
2327
so on up the tree.
1668
2328
 
1669
2329
Logically a 'DEFAULT' section should apply to all subsections of the *same
1670
 
parent*: this means that checking the 'DEFAULT' sub-section in the *current
1671
 
section* is not necessarily logical ?
1672
 
 
1673
 
In order to simplify Unicode support (which is possibly of limited value
1674
 
in a config file ?) I have removed automatic support, and added thev``encode``
1675
 
and ``decode`` methods. These can be used to transform keys and entries.
1676
 
Because the regex looks for specific values on inital parsing (i.e. the quotes
1677
 
and the equals signs) it can only read ASCII compatible encodings. For Unicode
1678
 
I suggest ``UTF8``, which is ASCII compatible.
1679
 
 
1680
 
.. note::
1681
 
 
1682
 
    There is no reason why you shouldn't decode your config file into Unicode
1683
 
    before passing them to ConfigObj (as a list of lines). This should give you
1684
 
    Unicode keys and values.
1685
 
 
1686
 
Does it matter that we don't support the ':' divider, which is supported by
1687
 
``ConfigParser`` ?
1688
 
 
1689
 
Following error with "list_values=False" : ::
1690
 
 
1691
 
    >>> a = ["a='hello', 'goodbye'"]
1692
 
    >>>
1693
 
    >>> c(a, list_values=False)
1694
 
    {'a': "hello', 'goodbye"}
1695
 
 
1696
 
The regular expression correctly removes the value - ``"'hello', 'goodbye'"`` -
1697
 
and then unquote just removes the front and back quotes (called by
1698
 
``_handle_value``). What should we do ?? We *ought* to raise an exception - 
1699
 
because if lists are off it's an invalid value. This is not desired if you want 
1700
 
to do your own list processing e.g. using listquote for nested lists. It would
1701
 
be *better* in this case not to unquote. Raising an exception would require a
1702
 
new regex.
1703
 
 
1704
 
String interpolation and validation don't play well together. See 
1705
 
`Validation and Interpolation`_.
 
2330
parent* - this means that checking the 'DEFAULT' subsection in the
 
2331
*current section* is not necessarily logical ?
 
2332
 
 
2333
Does it matter that we don't support the ':' divider, which is supported
 
2334
by ``ConfigParser`` ?
 
2335
 
 
2336
String interpolation and validation don't play well together. When
 
2337
validation changes type it sets the value. This will correctly fetch the
 
2338
value using interpolation - but then overwrite the interpolation reference.
 
2339
If the value is unchanged by validation (it's a string) - but other types
 
2340
will be.
 
2341
 
1706
2342
 
1707
2343
CHANGELOG
1708
2344
=========
1709
2345
 
1710
2346
This is an abbreviated changelog showing the major releases up to version 4.
1711
2347
From version 4 it lists all releases and changes. *More* data on individual
1712
 
changes may be found in the source code.
 
2348
changes may be found in the source code or the CHANGELOG file.
 
2349
 
 
2350
 
 
2351
2007/02/04 - Version 4.4.0
 
2352
--------------------------
 
2353
 
 
2354
Official release of 4.4.0
 
2355
 
 
2356
 
 
2357
2006/12/17 - Version 4.3.3-alpha4
 
2358
---------------------------------
 
2359
 
 
2360
By Nicola Larosa
 
2361
 
 
2362
Allowed arbitrary indentation in the ``indent_type`` parameter, removed the
 
2363
``NUM_INDENT_SPACES`` and ``MAX_INTERPOL_DEPTH`` (a leftover) constants,
 
2364
added indentation tests (including another docutils workaround, sigh), updated
 
2365
the documentation.
 
2366
 
 
2367
By Michael Foord
 
2368
 
 
2369
Made the import of ``compiler`` conditional so that ``ConfigObj`` can be used
 
2370
with `IronPython <http://www.codeplex.com/IronPython>`_.
 
2371
 
 
2372
 
 
2373
2006/12/17 - Version 4.3.3-alpha3
 
2374
---------------------------------
 
2375
 
 
2376
By Nicola Larosa
 
2377
 
 
2378
Added a missing ``self.`` in the _handle_comment method and a related test,
 
2379
per Sourceforge bug #1523975.
 
2380
 
 
2381
 
 
2382
2006/12/09 - Version 4.3.3-alpha2
 
2383
---------------------------------
 
2384
 
 
2385
By Nicola Larosa
 
2386
 
 
2387
Changed interpolation search strategy, based on this patch by Robin Munn:
 
2388
http://sourceforge.net/mailarchive/message.php?msg_id=17125993
 
2389
 
 
2390
 
 
2391
2006/12/09 - Version 4.3.3-alpha1
 
2392
---------------------------------
 
2393
 
 
2394
By Nicola Larosa
 
2395
 
 
2396
Added Template-style interpolation, with tests, based on this patch by
 
2397
Robin Munn: http://sourceforge.net/mailarchive/message.php?msg_id=17125991
 
2398
(awful archives, bad Sourceforge, bad).
 
2399
 
 
2400
 
 
2401
2006/06/04 - Version 4.3.2
 
2402
--------------------------
 
2403
 
 
2404
Changed error handling, if parsing finds a single error then that error will
 
2405
be re-raised. That error will still have an ``errors`` and a ``config``
 
2406
attribute.
 
2407
 
 
2408
Fixed bug where '\n' terminated files could be truncated.
 
2409
 
 
2410
Bugfix in ``unrepr`` mode, it couldn't handle '#' in values. (Thanks to
 
2411
Philippe Normand for the report.)
 
2412
 
 
2413
As a consequence of this fix, ConfigObj doesn't now keep inline comments in
 
2414
``unrepr`` mode. This is because the parser in the `compiler package`_
 
2415
doesn't keep comments. {sm;:-)}
 
2416
 
 
2417
Error messages are now more useful. They tell you the number of parsing errors
 
2418
and the line number of the first error. (In the case of multiple errors.)
 
2419
 
 
2420
Line numbers in exceptions now start at 1, not 0.
 
2421
 
 
2422
Errors in ``unrepr`` mode are now handled the same way as in the normal mode.
 
2423
The errors stored will be an ``UnreprError``.
 
2424
 
 
2425
 
 
2426
2006/04/29 - Version 4.3.1
 
2427
--------------------------
 
2428
 
 
2429
Added ``validate.py`` back into ``configobj.zip``. (Thanks to Stewart
 
2430
Midwinter)
 
2431
 
 
2432
Updated to `validate.py`_ 0.2.2.
 
2433
 
 
2434
Preserve tuples when calling the ``dict`` method. (Thanks to Gustavo Niemeyer.)
 
2435
 
 
2436
Changed ``__repr__`` to return a string that contains ``ConfigObj({ ... })``.
 
2437
 
 
2438
Change so that an options dictionary isn't modified by passing it to ConfigObj.
 
2439
(Thanks to Artarious.)
 
2440
 
 
2441
Added ability to handle negative integers in ``unrepr``. (Thanks to Kevin
 
2442
Dangoor.)
 
2443
 
 
2444
 
 
2445
2006/03/24 - Version 4.3.0
 
2446
--------------------------
 
2447
 
 
2448
Moved the tests and the CHANGELOG (etc) into a separate file. This has reduced
 
2449
the size of ``configobj.py`` by about 40%.
 
2450
 
 
2451
Added the ``unrepr`` mode to reading and writing config files. Thanks to Kevin
 
2452
Dangoor for this suggestion.
 
2453
 
 
2454
Empty values are now valid syntax. They are read as an empty string ``''``.
 
2455
(``key =``, or ``key = # comment``.)
 
2456
 
 
2457
``validate`` now honours the order of the configspec.
 
2458
 
 
2459
Added the ``copy`` mode to validate. Thanks to Louis Cordier for this
 
2460
suggestion.
 
2461
 
 
2462
Fixed bug where files written on windows could be given ``'\r\r\n'`` line
 
2463
terminators.
 
2464
 
 
2465
Fixed bug where last occurring comment line could be interpreted as the
 
2466
final comment if the last line isn't terminated.
 
2467
 
 
2468
Fixed bug where nested list values would be flattened when ``write`` is
 
2469
called. Now sub-lists have a string representation written instead.
 
2470
 
 
2471
Deprecated ``encode`` and ``decode`` methods instead.
 
2472
 
 
2473
You can now pass in a ConfigObj instance as a configspec (remember to read
 
2474
the configspec file using ``list_values=False``).
 
2475
 
 
2476
Sorted footnotes in the docs.
 
2477
 
 
2478
 
 
2479
2006/02/16 - Version 4.2.0
 
2480
--------------------------
 
2481
 
 
2482
Removed ``BOM_UTF8`` from ``__all__``.
 
2483
 
 
2484
The ``BOM`` attribute has become a boolean. (Defaults to ``False``.) It is
 
2485
*only* ``True`` for the ``UTF16/UTF8`` encodings.
 
2486
 
 
2487
File like objects no longer need a ``seek`` attribute.
 
2488
 
 
2489
Full unicode support added. New options/attributes ``encoding``,
 
2490
``default_encoding``.
 
2491
 
 
2492
ConfigObj no longer keeps a reference to file like objects. Instead the
 
2493
``write`` method takes a file like object as an optional argument. (Which
 
2494
will be used in preference of the ``filename`` attribute if that exists as
 
2495
well.)
 
2496
 
 
2497
utf16 files decoded to unicode.
 
2498
 
 
2499
If ``BOM`` is ``True``, but no encoding specified, then the utf8 BOM is
 
2500
written out at the start of the file. (It will normally only be ``True`` if
 
2501
the utf8 BOM was found when the file was read.)
 
2502
 
 
2503
Thanks to Aaron Bentley for help and testing on the unicode issues.
 
2504
 
 
2505
File paths are *not* converted to absolute paths, relative paths will
 
2506
remain relative as the ``filename`` attribute.
 
2507
 
 
2508
Fixed bug where ``final_comment`` wasn't returned if ``write`` is returning
 
2509
a list of lines.
 
2510
 
 
2511
Deprecated ``istrue``, replaced it with ``as_bool``.
 
2512
 
 
2513
Added ``as_int`` and ``as_float``.
 
2514
 
 
2515
2005/12/14 - Version 4.1.0
 
2516
--------------------------
 
2517
 
 
2518
Added ``merge``, a recursive update.
 
2519
 
 
2520
Added ``preserve_errors`` to ``validate`` and the ``flatten_errors``
 
2521
example function.
 
2522
 
 
2523
Thanks to Matthew Brett for suggestions and helping me iron out bugs.
 
2524
    
 
2525
Fixed bug where a config file is *all* comment, the comment will now be
 
2526
``initial_comment`` rather than ``final_comment``.
 
2527
 
 
2528
Validation no longer done on the 'DEFAULT' section (only in the root level).
 
2529
This allows interpolation in configspecs.
 
2530
 
 
2531
Also use the new list syntax in validate_ 0.2.1. (For configspecs).
 
2532
 
 
2533
2005/12/02 - Version 4.0.2
 
2534
--------------------------
 
2535
 
 
2536
Fixed bug in ``create_empty``. Thanks to Paul Jimenez for the report.
 
2537
 
 
2538
 
 
2539
2005/11/05 - Version 4.0.1
 
2540
--------------------------
 
2541
 
 
2542
Fixed bug in ``Section.walk`` when transforming names as well as values.
 
2543
 
 
2544
Added the ``istrue`` method. (Fetches the boolean equivalent of a string
 
2545
value).
 
2546
 
 
2547
Fixed ``list_values=False`` - they are now only quoted/unquoted if they
 
2548
are multiline values.
 
2549
 
 
2550
List values are written as ``item, item`` rather than ``item,item``.
 
2551
 
1713
2552
 
1714
2553
2005/10/17 - Version 4.0.0
1715
2554
--------------------------
1869
2708
-------
1870
2709
 
1871
2710
ConfigObj originated in a set of functions for reading config files in the
1872
 
atlantibots_ project. The original functions were written by Rob McNeur...
 
2711
`atlantibots <http://www.voidspace.org.uk/atlantibots/>`_ project. The original
 
2712
functions were written by Rob McNeur.
1873
2713
 
1874
 
.. _atlantibots: http://www.voidspace.org.uk/atlantibots
1875
2714
 
1876
2715
----------
1877
2716
 
1878
2717
Footnotes
1879
2718
=========
1880
2719
 
1881
 
.. [#] The core parser is now based on regular expressions, so it's a lot
1882
 
    faster.
1883
 
 
1884
 
.. [#] 134 of them, at the time of writing.
 
2720
.. [#] 315 of them, at the time of writing.
1885
2721
 
1886
2722
.. [#] And if you discover any bugs, let us know. We'll fix them quickly.
1887
2723
 
1888
2724
.. [#] If you specify a filename that doesn't exist, ConfigObj will assume you
1889
2725
    are creating a new one. See the *create_empty* and *file_error* options_.
1890
2726
 
1891
 
.. [#] They can be byte strings ('ordinary' strings) or Unicode. If they are
1892
 
    Unicode then ConfigObj will have to do an implicit encode before writing.
1893
 
    See the encodings_ section for more details.
 
2727
.. [#] They can be byte strings (*ordinary* strings) or Unicode.
1894
2728
 
1895
2729
.. [#] Except we don't support the RFC822 style line continuations, nor ':' as
1896
2730
    a divider.
1897
2731
 
1898
 
.. [#] For a file object that will depend what mode it was opened with. You
1899
 
    can read *and* write to a ``StringIO`` instance, but not always to a
1900
 
    ``cStringIO`` instance.
 
2732
.. [#] This is a change in ConfigObj 4.2.0. Note that ConfigObj doesn't call
 
2733
    the seek method of any file like object you pass in. You may want to call
 
2734
    ``file_object.seek(0)`` yourself, first.
1901
2735
 
1902
2736
.. [#] A side effect of this is that it enables you to copy a ConfigObj :
1903
2737
 
1904
 
.. raw:: html
1905
 
 
1906
 
    {+coloring}
1907
 
 
1908
 
    # only copies members
1909
 
    # not attributes/comments
1910
 
    config2 = ConfigObj(config1)
1911
 
 
1912
 
    {-coloring}
1913
 
 
1914
 
..
 
2738
    .. raw:: html
 
2739
    
 
2740
        {+coloring}
 
2741
    
 
2742
        # only copies members
 
2743
        # not attributes/comments
 
2744
        config2 = ConfigObj(config1)
 
2745
    
 
2746
        {-coloring}
1915
2747
 
1916
2748
    The order of values and sections will not be preserved, though.
1917
2749
 
1918
2750
.. [#] Other than lists of strings.
1919
2751
 
1920
 
.. [#] The method signature in the API docs will show that it does in fact
1921
 
    take one argument: the section to be written. This is because the
1922
 
    ``write`` method is called recursively. Using this argument *forces* write
1923
 
    to return a list of lines, so it's probably not very useful to you.
 
2752
.. [#] The exception is if it detects a ``UTF16`` encoded file which it
 
2753
    must decode before parsing.
 
2754
     
 
2755
.. [#] The method signature in the API docs will show that this method takes
 
2756
    two arguments. The second is the section to be written. This is because the
 
2757
    ``write`` method is called recursively.
1924
2758
 
1925
2759
.. [#] The dict method doesn't actually use the deepcopy mechanism. This means
1926
2760
    if you add nested lists (etc) to your ConfigObj, then the dictionary
1931
2765
    change the value by setting ``section[key] = newval``. It also gives you
1932
2766
    access to the *rename* method of the section.
1933
2767
 
1934
 
.. [#] A current bug in unquoting when ``list_values=False`` currently makes
1935
 
    this impossible. We are considering the best way to fix this.
1936
 
 
1937
2768
.. [#] Minimum required version of *validate.py* 0.2.0 .
1938
2769
 
1939
 
.. [#] There's nothing to stop you decoding the whole config file to Unicode
1940
 
    *first*.
1941
 
 
1942
2770
.. [#] It also makes ConfigObj a lot simpler to *use*.
1943
2771
 
1944
2772
.. note::
1950
2778
.. raw:: html
1951
2779
 
1952
2780
    <div align="center">
1953
 
        <a href="http://sourceforge.net/donate/index.php?group_id=123265">
1954
 
            <img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="Support This Project" /> 
1955
 
        </a>
1956
 
        <a href="http://sourceforge.net">
1957
 
            <img src="http://sourceforge.net/sflogo.php?group_id=123265&amp;type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" />
1958
 
        </a>
1959
 
        <br />
1960
 
        <a href="http://www.python.org">
1961
 
            <img src="images/powered_by_python.jpg" width="602" height="186" border="0" />
1962
 
        </a>
1963
 
        <a href="http://www.opensource.org">
1964
 
            <img src="images/osi-certified-120x100.gif" width="120" height="100" border="0" />
1965
 
            <br /><strong>Certified Open Source</strong>
1966
 
        </a>
1967
 
        <br /><br />
1968
 
        <script type="text/javascript" language="JavaScript">var site="s16atlantibots"</script>
1969
 
        <script type="text/javascript" language="JavaScript1.2" src="http://s16.sitemeter.com/js/counter.js?site=s16atlantibots"></script>
1970
 
        <noscript>
1971
 
            <a href="http://s16.sitemeter.com/stats.asp?site=s16atlantibots">
1972
 
                <img src="http://s16.sitemeter.com/meter.asp?site=s16atlantibots" alt="Site Meter" border=0 />
1973
 
            </a>
1974
 
        </noscript>
1975
 
        <br />
 
2781
        <p>
 
2782
            <a href="http://www.python.org">
 
2783
                <img src="images/new_python.gif" width="100" height="103" border="0" 
 
2784
                    alt="Powered by Python" />
 
2785
            </a>
 
2786
            <a href="http://sourceforge.net">
 
2787
                <img src="http://sourceforge.net/sflogo.php?group_id=123265&amp;type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" />
 
2788
            </a>
 
2789
            <a href="http://www.opensource.org">
 
2790
                <img src="images/osi-certified-120x100.gif" width="120" height="100" border="0"
 
2791
                    alt="Certified Open Source"/>
 
2792
            </a>
 
2793
        </p>
 
2794
        <p>
 
2795
            <a href="http://www.voidspace.org.uk/python/index.shtml">
 
2796
                <img src="images/pythonbanner.gif" width="468" height="60" 
 
2797
                alt="Python on Voidspace" border="0" />
 
2798
            </a>
 
2799
        </p>
 
2800
        <p>
 
2801
            <a href="http://sourceforge.net/donate/index.php?group_id=123265">
 
2802
                <img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="Support This Project" /> 
 
2803
            </a>
 
2804
        </p>
 
2805
        <p>
 
2806
            <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
 
2807
            </script>
 
2808
            <script type="text/javascript">
 
2809
            _uacct = "UA-203625-1";
 
2810
            urchinTracker();
 
2811
            </script>
 
2812
        </p>
 
2813
 
1976
2814
    </div>
1977
2815
 
1978
2816
.. _listquote: http://www.voidspace.org.uk/python/modules.shtml#listquote
1979
 
.. _Michael Foord: http://www.voidspace.org.uk
 
2817
.. _Michael Foord: http://www.voidspace.org.uk/index2.shtml
1980
2818
.. _Nicola Larosa: http://www.teknico.net
1981
2819
.. _Mark Andrews: http://www.la-la.com