Skip to content

Commit

Permalink
adding loader arg for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Aug 15, 2015
1 parent 631c0ee commit 4a49e00
Show file tree
Hide file tree
Showing 9 changed files with 687 additions and 116 deletions.
128 changes: 126 additions & 2 deletions README.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"%load_ext yamlmagic"
"%reload_ext yamlmagic"
]
},
{
Expand Down Expand Up @@ -209,6 +209,130 @@
"x"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By default, `yaml.SafeLoader` will be used, which won't allow the [powerful but dangerous](http://pyyaml.org/wiki/PyYAMLDocumentation#LoadingYAML) (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..."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from yaml import Loader\n",
"class FooLoader(Loader):\n",
" # some special things you have built\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"application/javascript": [
"\n",
" require(\n",
" [\n",
" \"notebook/js/codecell\",\n",
" \"codemirror/mode/yaml/yaml\"\n",
" ],\n",
" function(cc){\n",
" cc.CodeCell.options_default.highlight_modes.magic_yaml = {\n",
" reg: [\"^%%yaml\"]\n",
" }\n",
" }\n",
" );\n",
" "
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"[{'a': 1.0, 'b': 2.0}]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%yaml --loader FooLoader\n",
"- a: !!python/float 1\n",
" b: !!python/float 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"...or dotted-notation path to a loader:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"application/javascript": [
"\n",
" require(\n",
" [\n",
" \"notebook/js/codecell\",\n",
" \"codemirror/mode/yaml/yaml\"\n",
" ],\n",
" function(cc){\n",
" cc.CodeCell.options_default.highlight_modes.magic_yaml = {\n",
" reg: [\"^%%yaml\"]\n",
" }\n",
" }\n",
" );\n",
" "
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"[{'a': 1.0, 'b': 2.0}]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%yaml --loader yaml.Loader\n",
"- a: !!python/float 1\n",
" b: !!python/float 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
91 changes: 0 additions & 91 deletions README.md

This file was deleted.

0 comments on commit 4a49e00

Please sign in to comment.