brennivin.yamlext module¶
This module provides some utility functions for yaml, and automatically chooses the fastest yaml loader/dumper available automatically.
Traditional yaml usage can be replaced as follows:
Dumping to a file¶
with open(path, 'w') as f:
yaml.dump(obj, f)
=>
yamlext.dumpfile(obj, f)
Dumping to a string¶
s = yaml.dump(obj)
=>
s = yamlext.dumps(obj)
Dumping to a stream¶
Almost never a need to use this directly:
yaml.dump(obj, stream)
=>
yamlext.dump(obj, stream)
Loading from a file¶
with open(path) as f:
obj = yaml.load(f)
=>
obj = yamlext.loadfile(path)
Loading from a string¶
obj = yaml.load(s)
=>
obj = yamlext.loads(s)
Loading from a stream¶
Almost never a need to use this directly:
obj = yaml.load(stream)
=>
obj = yamlext.load(stream)