Ignore:
Timestamp:
04/18/06 13:15:54 (9 years ago)
Author:
xi
Message:

Add support for recursive nodes to Composer. Constructor does not support recursive objects though.

File:
1 edited

Legend:

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

    r139 r142  
    3030    def __init__(self): 
    3131        self.constructed_objects = {} 
     32        self.recursive_objects = {} 
    3233 
    3334    def check_data(self): 
     
    4849        data = self.construct_object(node) 
    4950        self.constructed_objects = {} 
     51        self.recursive_objects = {} 
    5052        return data 
    5153 
     
    5355        if node in self.constructed_objects: 
    5456            return self.constructed_objects[node] 
     57        if node in self.recursive_objects: 
     58            raise ConstructorError(None, None, 
     59                    "found recursive node", node.start_mark) 
     60        self.recursive_objects[node] = None 
    5561        constructor = None 
    5662        if node.tag in self.yaml_constructors: 
     
    8086        data = constructor(node) 
    8187        self.constructed_objects[node] = data 
     88        del self.recursive_objects[node] 
    8289        return data 
    8390 
Note: See TracChangeset for help on using the changeset viewer.