yamlmagic
an IPython magic for capturing data in YAML into a running IPython kernel.
Install
From the command line (or with ! in a notebook cell):
pip install yamlmagic
Enable
Ad-hoc
In the notebook, you can use the %load_ext or %reload_ext line magic.
%reload_ext yamlmagic
Configuration
In your profile’s ipython_kernel_config.py, you can add the following line to automatically load yamlmagic into all your running kernels:
c.InteractiveShellApp.extensions = ['yaml_magic']
Use
The %%yaml cell magic will either act as simple parser:
%%yaml
a_toplevel_key: 1
<IPython.core.display.Javascript object>
{'a_toplevel_key': 1}
which can be accessed by the special last result variable _:
_
{'a_toplevel_key': 1}
Or will update a named variable with the parsed document:
%%yaml x
- a: 1
b: 2
<IPython.core.display.Javascript object>
x
[{'a': 1, 'b': 2}]
By default, yaml.SafeLoader will be used, which won’t allow the powerful but dangerous (and unportable) `!python/ tags <http://pyyaml.org/wiki/PyYAMLDocumentation#YAMLtagsandPythontypes>`__. If you’d like to use them, provide the -l (or --loader) argument with a BaseLoader subclass available via a local variable…
from yaml import Loader
class FooLoader(Loader):
# some special things you have built
pass
%%yaml --loader FooLoader
!!python/float 0
<IPython.core.display.Javascript object>
0.0
…or dotted-notation path to a loader:
%%yaml --loader yaml.Loader
!!python/float 0
<IPython.core.display.Javascript object>
0.0
Contribute
Issues and pull requests welcome!
License
yamlmagic is released as free software under the BSD 3-Clause license.
Thank
[@tonyfast](http://robclewley.github.io) for asking for this
[@robclewley](http://robclewley.github.io) for documentation-shaming a gist into a module
Metadata
Release files for jademagic 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jademagic-0.1.0.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jademagic-0.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / jademagic-0.1.0.tar.gz
| Download URL | jademagic-0.1.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7cd647e83fd7ad45620f26b806d24c85af86216c0c540a3cdff38786971ce9f
|
|
BLAKE2b-256 checksum How to use checksums |
7343eb7178727a2caca097f0a552b77538ff4caf0c46504ca8d41a698c13f053
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / jademagic-0.1.0-py2.py3-none-any.whl
| Download URL | jademagic-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e0728b23201011d777aa091eb9df4ccb6b2e8dc9ce3c3b38181022f2dfbd834e
|
|
BLAKE2b-256 checksum How to use checksums |
474ff94cf542eeaba7ee2e9eaf1babd52bf3041f442f3782ec1b9ebdd7220d16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |