Custom YAML loader. Load all strings as Unicode. http://stackoverflow.com/a/2967461/3609487
(stream, loader=yaml.Loader)
| 15 | |
| 16 | |
| 17 | def yaml_load(stream, loader=yaml.Loader): |
| 18 | """ |
| 19 | Custom YAML loader. |
| 20 | |
| 21 | Load all strings as Unicode. |
| 22 | http://stackoverflow.com/a/2967461/3609487 |
| 23 | """ |
| 24 | |
| 25 | def construct_yaml_str(self, node): |
| 26 | """Override the default string handling function to always return Unicode objects.""" |
| 27 | |
| 28 | return self.construct_scalar(node) |
| 29 | |
| 30 | class Loader(loader): |
| 31 | """Custom Loader.""" |
| 32 | |
| 33 | Loader.add_constructor( |
| 34 | 'tag:yaml.org,2002:str', |
| 35 | construct_yaml_str |
| 36 | ) |
| 37 | |
| 38 | return yaml.load(stream, Loader) |
| 39 | |
| 40 | |
| 41 | def get_frontmatter(text): |
no outgoing calls
no test coverage detected