<jupyter_start><jupyter_text>yamlmagic> an [IPython](http://ipython.org/) [magic](https://ipython.org/ipython-doc/dev/interactive/tutorial.html) for capturing data in [YAML](http://yaml.org/) into a running IPython kernel.[![Build Status][svg]][status]![pypi][][svg]: https://travis-ci.org/bollwyvl/yamlmagic.svg?branch=master[status]: https://travis-ci.org/bollwyvl/yamlmagic[pypi]: https://pypip.in/version/yamlmagic/badge.svg?style=flat  InstallFrom the command line (or with `!` in a notebook cell):```bashpip install yamlmagic```  Enable Ad-hocIn the notebook, you can use the `%load_ext` or `%reload_ext` line magic.<jupyter_code>%reload_ext yamlmagic<jupyter_output><empty_output><jupyter_text>ConfigurationIn your profile's `ipython_kernel_config.py`, you can add the following line to automatically load `yamlmagic` into all your running kernels:```pythonc.InteractiveShellApp.extensions = ['yaml_magic']```  UseThe `%%yaml` cell magic will either act as simple parser:<jupyter_code>%%yaml
a_toplevel_key: 1<jupyter_output><empty_output><jupyter_text>which can be accessed by the special last result variable `_`:<jupyter_code>_<jupyter_output><empty_output><jupyter_text>Or will update a named variable with the parsed document:<jupyter_code>%%yaml x
- a: 1
  b: 2
x<jupyter_output><empty_output><jupyter_text>By default, `yaml.SafeLoader` will be used, which won't allow the [powerful but dangerous](http://pyyaml.org/wiki/PyYAMLDocumentationLoadingYAML) (and unportable) [`!python/` tags](http://pyyaml.org/wiki/PyYAMLDocumentationYAMLtagsandPythontypes). If you'd like to use them, provide the `-l` (or `--loader`) argument with a `BaseLoader` subclass available via a local variable...<jupyter_code>from yaml import Loader
class FooLoader(Loader):
    # some special things you have built
    pass
%%yaml --loader FooLoader
- a: !!python/float 1
  b: !!python/float 2<jupyter_output><empty_output><jupyter_text>...or dotted-notation path to a loader:<jupyter_code>%%yaml --loader yaml.Loader
- a: !!python/float 1
  b: !!python/float 2<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1341991341991342, 'fraction_numerical': 0.003367003367003367, 'mean_word_length': 6.647058823529412, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '520821', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 739, 'n_tokens_neox': 695, 'n_words': 171, 'path': 'README.ipynb', 'repo_name': 'bollwyvl/yamlmagic', 'size': '2079'}