Ignore:
Timestamp:
08/21/07 16:25:34 (7 years ago)
Author:
xi
Message:

Make compose() and load() ensure that the input stream contains a single document. Fixes #54.

File:
1 edited

Legend:

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

    r252 r258  
    3636    """ 
    3737    loader = Loader(stream) 
    38     if loader.check_node(): 
    39         return loader.get_node() 
     38    return loader.get_single_node() 
    4039 
    4140def compose_all(stream, Loader=Loader): 
     
    4847        yield loader.get_node() 
    4948 
     49def load(stream, Loader=Loader): 
     50    """ 
     51    Parse the first YAML document in a stream 
     52    and produce the corresponding Python object. 
     53    """ 
     54    loader = Loader(stream) 
     55    return loader.get_single_data() 
     56 
    5057def load_all(stream, Loader=Loader): 
    5158    """ 
     
    5764        yield loader.get_data() 
    5865 
    59 def load(stream, Loader=Loader): 
     66def safe_load(stream): 
    6067    """ 
    6168    Parse the first YAML document in a stream 
    6269    and produce the corresponding Python object. 
    63     """ 
    64     loader = Loader(stream) 
    65     if loader.check_data(): 
    66         return loader.get_data() 
     70    Resolve only basic YAML tags. 
     71    """ 
     72    return load(stream, SafeLoader) 
    6773 
    6874def safe_load_all(stream): 
     
    7379    """ 
    7480    return load_all(stream, SafeLoader) 
    75  
    76 def safe_load(stream): 
    77     """ 
    78     Parse the first YAML document in a stream 
    79     and produce the corresponding Python object. 
    80     Resolve only basic YAML tags. 
    81     """ 
    82     return load(stream, SafeLoader) 
    8381 
    8482def emit(events, stream=None, Dumper=Dumper, 
Note: See TracChangeset for help on using the changeset viewer.