Ticket #191: pyyaml_191.py

File pyyaml_191.py, 430 bytes (added by jesstess, 4 years ago)
Line 
1import yaml
2from yaml import CSafeDumper, SafeDumper, CSafeLoader, SafeLoader
3
4fd = open("/tmp/yaml_test.txt", "r+")
5
6try:
7    yaml.dump("Foobar", fd, Dumper=CSafeDumper)
8except AttributeError, e:
9    print e
10
11fd.seek(0)
12yaml.dump("Foobar", fd, Dumper=SafeDumper)
13
14try:
15    fd.seek(0)
16    print yaml.load(fd, Loader=CSafeLoader)
17except AttributeError, e:
18    print e
19
20fd.seek(0)
21print yaml.load(fd, Loader=SafeLoader)
22
23fd.close()