Ignore:
Timestamp:
08/03/06 12:07:29 (8 years ago)
Author:
xi
Message:

Subclass all base classes from object.

Hold references to the objects being represented (should fix #22).

The value of a mapping node is represented as a list of pairs (key, value)
now.

Sort dictionary items (fix #23).

Recursive structures are now loaded and dumped correctly, including complex
structures like recursive tuples (fix #5). Thanks Peter Murphy for the patches.
To make it possible, representer functions are allowed to be generators.
In this case, the first generated value is an object. Other values produced
by the representer are ignored.

Make Representer not try to guess !!pairs when a list is represented.
You need to construct a !!pairs node explicitly now.

Do not check for duplicate mapping keys as it didn't work correctly anyway.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/lib/yaml/composer.py

    r198 r222  
    99    pass 
    1010 
    11 class Composer: 
     11class Composer(object): 
    1212 
    1313    def __init__(self): 
     
    100100        if tag is None or tag == u'!': 
    101101            tag = self.resolve(MappingNode, None, start_event.implicit) 
    102         node = MappingNode(tag, {}, 
     102        node = MappingNode(tag, [], 
    103103                start_event.start_mark, None, 
    104104                flow_style=start_event.flow_style) 
     
    106106            self.anchors[anchor] = node 
    107107        while not self.check_event(MappingEndEvent): 
    108             key_event = self.peek_event() 
     108            #key_event = self.peek_event() 
    109109            item_key = self.compose_node(node, None) 
    110             if item_key in node.value: 
    111                 raise ComposerError("while composing a mapping", start_event.start_mark, 
    112                         "found duplicate key", key_event.start_mark) 
     110            #if item_key in node.value: 
     111            #    raise ComposerError("while composing a mapping", start_event.start_mark, 
     112            #            "found duplicate key", key_event.start_mark) 
    113113            item_value = self.compose_node(node, item_key) 
    114             node.value[item_key] = item_value 
     114            #node.value[item_key] = item_value 
     115            node.value.append((item_key, item_value)) 
    115116        end_event = self.get_event() 
    116117        node.end_mark = end_event.end_mark 
Note: See TracChangeset for help on using the changeset viewer.