Changes between Version 18 and Version 19 of PyYAMLDocumentation


Ignore:
Timestamp:
05/07/06 04:40:22 (9 years ago)
Author:
xi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PyYAMLDocumentation

    v18 v19  
    10811081}}} 
    10821082 
    1083 '''`construct(stream)`''' parses the given `stream` and returns a Python object constructed from 
     1083'''`load(stream)`''' parses the given `stream` and returns a Python object constructed from 
    10841084for the first document in the stream. If there are no documents in the stream, it returns `None`. 
    10851085 
    1086 '''`construct_all(stream)`''' parses the given `stream` and returns a sequence of Python objects 
     1086'''`load_all(stream)`''' parses the given `stream` and returns a sequence of Python objects 
    10871087corresponding to the documents in the stream. 
     1088 
     1089'''`safe_load(stream)`''' parses the given `stream` and returns a Python object constructed from 
     1090for the first document in the stream. If there are no documents in the stream, it returns `None`. 
     1091`safe_load` recognizes only standard YAML tags and cannot construct an arbitrary Python object. 
     1092 
     1093'''`safe_load_all(stream)`''' parses the given `stream` and returns a sequence of Python objects 
     1094corresponding to the documents in the stream. `safe_load_all` recognizes only standard YAML tags 
     1095and cannot construct an arbitrary Python object. 
    10881096 
    10891097'''`Loader.check_data()`''' returns `True` is there are more documents available in the stream. Otherwise 
     
    12311239==== Representer interface ==== 
    12321240 
     1241{{{ 
     1242#!python 
     1243dump(data, stream=None, Dumper=Dumper, 
     1244    default_style=None, 
     1245    default_flow_style=None, 
     1246    encoding='utf-8', 
     1247    explicit_start=None, 
     1248    explicit_end=None, 
     1249    version=None, 
     1250    tags=None, 
     1251    canonical=None, 
     1252    indent=None, 
     1253    width=None, 
     1254    allow_unicode=None, 
     1255    line_break=None) 
     1256dump_all(data, stream=None, Dumper=Dumper, ...) 
     1257 
     1258safe_dump(data, stream=None, ...) 
     1259safe_dump_all(data, stream=None, ...) 
     1260 
     1261Dumper.represent(data) 
     1262 
     1263def representer(dumper, data): 
     1264    # ... 
     1265    return node 
     1266 
     1267def multi_representer(dumper, data): 
     1268    # ... 
     1269    return node 
     1270 
     1271add_representer(data_type, representer, Dumper=Dumper) 
     1272add_multi_representer(base_data_type, multi_representer, Dumper=Dumper) 
     1273 
     1274Dumper.add_representer(data_type, representer) # Dumper.add_representer is a class method. 
     1275Dumper.add_multi_representer(base_data_type, multi_representer) # Dumper.add_multi_representer is a class method. 
     1276 
     1277Dumper.represent_scalar(tag, value, style=None) 
     1278Dumper.represent_sequence(tag, value, flow_style=None) 
     1279Dumper.represent_mapping(tag, value, flow_style=None) 
     1280}}} 
     1281 
     1282'''`dump(data, stream=None)`''' serializes the given Python object into the `stream`. 
     1283If `stream` is `None`, it returns the produced stream. 
     1284 
     1285'''`dump_all(data, stream=None)`''' serializes the given sequence of Python objects 
     1286into the given `stream`. If `stream` is `None`, it returns the produced stream. 
     1287Each object is represented as a YAML document. 
     1288 
     1289'''`safe_dump(data, stream=None)`''' serializes the given Python object into the `stream`. 
     1290If `stream` is `None`, it returns the produced stream. `safe_dump` produces only standard YAML 
     1291tags and cannot represent an arbitrary Python object. 
     1292 
     1293'''`safe_dump_all(data, stream=None)`''' serializes the given sequence of Python objects 
     1294into the given `stream`. If `stream` is `None`, it returns the produced stream. 
     1295Each object is represented as a YAML document.  `safe_dump_all` produces only standard YAML 
     1296tags and cannot represent an arbitrary Python object. 
     1297 
     1298'''`Dumper.represent(data)`''' serializes the given Python object to the output YAML stream. 
     1299 
     1300'''`add_representer(data_type, representer)`''' and '''`Dumper.add_representer(data_type, representer)`''' 
     1301allow to specify a `representer` for Python objects of the given `data_type`. A representer is a function 
     1302that converts a native Python object to a node of a YAML representation graph. A representer accepts 
     1303an instance of `Dumper` and an object and returns a node. 
     1304 
     1305'''`add_multi_representer(base_data_type, multi_representer)`''' and '''`Dumper.add_multi_representer(base_data_type, multi_representer)`''' 
     1306allow to specify a `multi_representer` for Python objects of the given `base_data_type` or any of its subclasses. 
     1307A multi-representer is a function that converts a native Python object to a node of a YAML representation graph. 
     1308A multi-representer accepts an instance of `Dumper` and an object and returns a node. 
     1309 
     1310'''`Dumper.represent_scalar(tag, value, style=None)`''' returns a scalar node with the given `tag`, `value`, and `style`. 
     1311This function is intended to be used in representers. 
     1312 
     1313'''`Dumper.represent_sequence(tag, sequence, flow_style=None)`''' return a sequence node with the given `tag` 
     1314and subnodes generated from the items of the given `sequence`. 
     1315 
     1316'''`Dumper.represent_mapping(tag, mapping, flow_style=None)`''' return a mapping node with the given `tag` 
     1317and subnodes generated from the keys and values of the given `mapping`. 
     1318 
    12331319 
    12341320==== Resolver interface ==== 
     1321 
     1322The ''Resolver'' interfaces of '''`Loader`''' and '''`Dumper`''' are identical. Check the corresponding section 
     1323of the '''`Loader`''' reference. 
    12351324 
    12361325