diff options
author | Julian Berman <Julian@GrayVines.com> | 2020-08-28 16:31:33 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2020-08-28 16:31:33 -0400 |
commit | 7d552e9ed16488e48faaca034b8645f86cff9334 (patch) | |
tree | f2ac1ef573b1d0140ab6e1264cdb2abbea012e7f | |
parent | 534ac0b08dccc1d92cc710975dd9d356f5e12a4b (diff) | |
download | jsonschema-7d552e9ed16488e48faaca034b8645f86cff9334.tar.gz |
Remove the rest of the notebooks.ai related resources.
-rw-r--r-- | DEMO.ipynb | 167 | ||||
-rw-r--r-- | demo.yml | 2 | ||||
-rw-r--r-- | tox.ini | 6 |
3 files changed, 0 insertions, 175 deletions
diff --git a/DEMO.ipynb b/DEMO.ipynb deleted file mode 100644 index f008b79..0000000 --- a/DEMO.ipynb +++ /dev/null @@ -1,167 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# jsonschema\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`jsonschema` is an implementation of [JSON Schema](https://json-schema.org) for Python (supporting 2.7+ including Python 3)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Usage" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from jsonschema import validate" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# A sample schema, like what we'd get from json.load()\n", - "schema = {\n", - " \"type\" : \"object\",\n", - " \"properties\" : {\n", - " \"price\" : {\"type\" : \"number\"},\n", - " \"name\" : {\"type\" : \"string\"},\n", - " },\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# If no exception is raised by validate(), the instance is valid.\n", - "validate(instance={\"name\" : \"Eggs\", \"price\" : 34.99}, schema=schema)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "ename": "ValidationError", - "evalue": "'Invalid' is not of type 'number'\n\nFailed validating 'type' in schema['properties']['price']:\n {'type': 'number'}\n\nOn instance['price']:\n 'Invalid'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-5-e1e543273d1f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m validate(\n\u001b[1;32m 2\u001b[0m \u001b[0minstance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m\"name\"\u001b[0m \u001b[0;34m:\u001b[0m \u001b[0;34m\"Eggs\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"price\"\u001b[0m \u001b[0;34m:\u001b[0m \u001b[0;34m\"Invalid\"\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mschema\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mschema\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m )\n", - "\u001b[0;32m~/Development/jsonschema/jsonschema/validators.py\u001b[0m in \u001b[0;36mvalidate\u001b[0;34m(instance, schema, cls, *args, **kwargs)\u001b[0m\n\u001b[1;32m 899\u001b[0m \u001b[0merror\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mexceptions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbest_match\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalidator\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0miter_errors\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minstance\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 900\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0merror\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 901\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0merror\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 902\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 903\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mValidationError\u001b[0m: 'Invalid' is not of type 'number'\n\nFailed validating 'type' in schema['properties']['price']:\n {'type': 'number'}\n\nOn instance['price']:\n 'Invalid'" - ] - } - ], - "source": [ - "validate(\n", - " instance={\"name\" : \"Eggs\", \"price\" : \"Invalid\"},\n", - " schema=schema,\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It can also be used from console:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "!echo '{\"name\" : \"Eggs\", \"price\" : 34.99}' > /tmp/sample.json" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "!echo '{\"type\" : \"object\", \"properties\" : {\"price\" : {\"type\" : \"number\"}, \"name\" : {\"type\" : \"string\"}}}' > /tmp/sample.schema" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "!jsonschema -i /tmp/sample.json /tmp/sample.schema" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Do your own experiments here..." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Try `jsonschema` youself by adding your code below and running your own experiments 👇" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import jsonschema\n", - "\n", - "# your code here\n", - "jsonschema." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.4" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/demo.yml b/demo.yml deleted file mode 100644 index 0e9755f..0000000 --- a/demo.yml +++ /dev/null @@ -1,2 +0,0 @@ -requirements: - - jsonschema==3.2.0 @@ -1,7 +1,6 @@ [tox] envlist = py{36,37,38,py3}-{noextra,format,format_nongpl}-{build,tests}, - demo readme safety secrets @@ -43,11 +42,6 @@ deps = deps = bandit commands = {envbindir}/bandit --recursive {toxinidir}/jsonschema -[testenv:demo] -deps = jupyter -commands = - {envbindir}/jupyter nbconvert --output-dir {envtmpdir} {toxinidir}/DEMO.ipynb - [testenv:readme] deps = docutils |