Did I find the right examples for you? yes no

All Samples(12)  |  Call(12)  |  Derive(0)  |  Import(0)
Dump configuration from dictionary, returning a string.

Dump configuration from dictionary data, prepending string
comments from corresponding values (i.e. associated to the
matching keys in data) in comments. If pedantic is True, a
TypeError exception will be raised if some value in data is a
derivate class of an otherwise supported type. Return the
formatted string on success, or raise a TypeError or ValueError on
error. data dictionary is dumped in identifiers' alphabetical
order. Valid keywords are optional arguments to the low-level(more...)

        def dump(data, comments={}, pedantic=True, **kw):
    """
    Dump configuration from dictionary, returning a string.

    Dump configuration from dictionary data, prepending string
    comments from corresponding values (i.e. associated to the
    matching keys in data) in comments. If pedantic is True, a
    TypeError exception will be raised if some value in data is a
    derivate class of an otherwise supported type. Return the
    formatted string on success, or raise a TypeError or ValueError on
    error. data dictionary is dumped in identifiers' alphabetical
    order. Valid keywords are optional arguments to the low-level
    PrettyPrinter object (see the pformat method from the pprint
    module).

    === Note on comments ===

    If every lines in a comment string are already starting with a
    pound sign ('#') thus making the string an already valid Python
    comment, such string is preserved untouched in the output. If not,
    the comment string will be formatted using format_header(), using
    the same width used by the PrettyPrinter. Basically, this means
    you are free to either have comments automatically formatted and
    wrapped as a single paragraph, or use your own layout if you want,
    as long as the whole string keeps being a valid Python comment.

    Values associated with special '--top--' and '--bottom--' keys, if
    they exist in comments, will be respectively included at the
    beginning and end of the return string; same formatting
    rules apply to them.
    """
    return _Dump()(data, headers=comments, pedantic=pedantic, **kw)
        


src/m/i/miniconf-1.2.0/test_miniconf.py   miniconf(Download)
    def test_empty(self):
        # Test an empty dump
        out = miniconf.dump({})
        self.assertEqual(out, '')
 
    def test_subclass_dump_non_pedantic(self):
        # Test a subclass dump, in non-pedantic mode
        out = miniconf.dump({'spam' : self.MyInt(1)}, pedantic=False)
        self.assertEqual(out, 'spam = 1')
 
    def test_comment(self):
        # Test generation of a single comment
        out = miniconf.dump({}, comments = {'--top--': 'Egg'})
        self.assertEqual(out, '# Egg')
 
    def test_all_around_flat_dump(self):
        # Test the dump a single value of each supported type
        for value in (dict(), list(), tuple(),
                      int(), float(), str(), unicode(), bool(), None):
            out = miniconf.dump({'spam': value})
    def test_recursive_dump(self):
        # Test the dump of an arbitrary, nested structure 
        val = [0, {1: [2, (3, 4)]}]
        out = miniconf.dump({ 'spam': val})
        self.assertEqual(out, 'spam = %s' % repr(val))