Changes between Version 14 and Version 15 of PyYAMLDocumentation


Ignore:
Timestamp:
05/07/06 03:23:42 (9 years ago)
Author:
xi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PyYAMLDocumentation

    v14 v15  
    991991}}} 
    992992 
    993 The function '''`scan(stream)`''' scans the given `stream` and produces a sequence of tokens. 
    994  
    995 The method '''`Loader.check_token(*TokenClasses)`''' returns `True` if the next token in the stream 
     993'''`scan(stream)`''' scans the given `stream` and produces a sequence of tokens. 
     994 
     995'''`Loader.check_token(*TokenClasses)`''' returns `True` if the next token in the stream 
    996996is an instance of one of the given `TokenClasses`. Otherwise it returns `False`. 
    997997 
    998 The method '''`Loader.peek_token()`''' returns the next token in the stream, but does not remove 
     998'''`Loader.peek_token()`''' returns the next token in the stream, but does not remove 
    999999it from the internal token queue. The function returns `None` at the end of the stream. 
    10001000 
    1001 The method '''`Loader.get_token()`''' returns the next token in the stream and removes 
     1001'''`Loader.get_token()`''' returns the next token in the stream and removes 
    10021002it from the internal token queue. The function returns `None` at the end of the stream. 
    10031003 
     
    10141014}}} 
    10151015 
    1016 The function '''`parse(stream)`''' parses the given `stream` and produces a sequence of parsing events. 
    1017  
    1018 The method '''`Loader.check_event(*EventClasses)`''' returns `True` if the next event in the stream 
     1016'''`parse(stream)`''' parses the given `stream` and produces a sequence of parsing events. 
     1017 
     1018'''`Loader.check_event(*EventClasses)`''' returns `True` if the next event in the stream 
    10191019is an instance of one of the given `EventClasses`. Otherwise it returns `False`. 
    10201020 
    1021 The method '''`Loader.peek_event()`''' returns the next event in the stream, but does not remove 
     1021'''`Loader.peek_event()`''' returns the next event in the stream, but does not remove 
    10221022it from the internal event queue. The function returns `None` at the end of the stream. 
    10231023 
    1024 The method '''`Loader.get_event()`''' returns the next event in the stream and removes 
     1024'''`Loader.get_event()`''' returns the next event in the stream and removes 
    10251025it from the internal event queue. The function returns `None` at the end of the stream. 
    10261026 
     
    10511051 
    10521052==== Constructor interface ==== 
     1053 
     1054{{{ 
     1055#!python 
     1056load(stream, Loader=Loader) 
     1057load_all(stream, Loader=Loader) 
     1058 
     1059safe_load(stream) 
     1060safe_load_all(stream) 
     1061 
     1062Loader.check_data() 
     1063Loader.get_data() 
     1064 
     1065def constructor(loader, node): 
     1066    # ... 
     1067    return data 
     1068 
     1069def multi_constructor(loader, tag_suffix, node): 
     1070    # ... 
     1071    return data 
     1072 
     1073add_constructor(tag, constructor, Loader=Loader) 
     1074add_multi_constructor(tag_prefix, multi_constructor, Loader=Loader) 
     1075 
     1076Loader.add_constructor(tag, constructor) # Loader.add_constructor is a class method. 
     1077Loader.add_multi_constructor(tag_prefix, multi_constructor) # Loader.add_multi_constructor is a class method. 
     1078 
     1079Loader.construct_scalar(node) 
     1080Loader.construct_sequence(node) 
     1081Loader.construct_mapping(node) 
     1082}}} 
     1083 
     1084'''`construct(stream)`''' parses the given `stream` and returns a Python object constructed from 
     1085for the first document in the stream. If there are no documents in the stream, it returns `None`. 
     1086 
     1087'''`construct_all(stream)`''' parses the given `stream` and returns a sequence of Python objects 
     1088corresponding to the documents in the stream. 
     1089 
     1090'''`Loader.check_data()`''' returns `True` is there are more documents available in the stream. Otherwise 
     1091it returns `False`. 
     1092 
     1093'''`Loader.get_data()`''' constructs and returns a Python object corresponding to the next document 
     1094in the stream. 
     1095 
     1096'''`add_constructor(tag, constructor)`''' and '''`Loader.add_constructor(tag, constructor)`''' allow 
     1097to specify a `constructor` for the given `tag`. A constructor is a function that converts a node 
     1098of a YAML representation graph to a native Python object. A constructor accepts an instance of `Loader` 
     1099and a node and returns a Python object. 
     1100 
     1101'''`add_multi_constructor(tag_prefix, multi_constructor)`''' and '''`Loader.add_multi_constructor(tag_prefix, multi_constructor)`''' 
     1102allow to specify a `multi_constructor` for the given `tag_prefix`. A multi-constructor is a function that converts a node 
     1103of a YAML representation graph to a native Python object. A multi-constructor accepts an instance of `Loader`, 
     1104the suffix of the node tag, and a node and returns a Python object. 
     1105 
     1106'''`Loader.construct_scalar(node)`''' checks that the given `node` is a scalar and returns its value. 
     1107This function is intended to be used in constructors. 
     1108 
     1109'''`Loader.construct_sequence(node)`''' checks that the given `node` is a sequence and returns a list 
     1110of Python objects corresponding to the node items. This function is intended to be used in constructors. 
     1111 
     1112'''`Loader.construct_mapping(node)`''' checks that the given `node` is a mapping and returns a dictionary 
     1113of Python objects corresponding to the node keys and values. This function is intended to be used in constructors. 
    10531114 
    10541115