{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Test `pidgy.runpidgy`" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " import pidgy" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " import pidgy" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " >>> dir(pidgy.runpidgy)\n", " ['Runner', '__all__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__test__', 'ast', 'importlib', 'pidgy', 'render', 'run', 'runpy', 'types']" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " >>> dir(pidgy.runpidgy)\n", " ['Runner', '__all__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__test__', 'ast', 'importlib', 'pidgy', 'render', 'run', 'runpy', 'types']" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " foo = None" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " foo = None" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "The `\"templated_document.md\"` file has `foo` annotated meaning that it will be recognized as CLI parameter." ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "The `\"templated_document.md\"` file has `foo` annotated meaning that it will be recognized as CLI parameter." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " >>> pidgy.runpidgy.run('templated_document.md')\n", " __main__\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " >>> pidgy.runpidgy.run('templated_document.md')\n", " __main__\n", " " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " >>> pidgy.runpidgy.render('templated_document.md')\n", " __main__\n", " \"\\n...foo... is defined as 42\\n\\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\\n\"" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " >>> pidgy.runpidgy.render('templated_document.md')\n", " __main__\n", " \"\\n...foo... is defined as 42\\n\\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\\n\"" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " >>> pidgy.runpidgy.render('templated_document.md', foo=900)\n", " __main__\n", " \"\\n...foo... is defined as 900\\n\\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\\n\"" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " >>> pidgy.runpidgy.render('templated_document.md', foo=900)\n", " __main__\n", " \"\\n...foo... is defined as 900\\n\\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\\n\"" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " runner = pidgy.runpidgy.Runner('templated_document.md')" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " runner = pidgy.runpidgy.Runner('templated_document.md')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " >>> runner.render(foo=900)\n", " __main__\n", " \"\\n...foo... is defined as 900\\n\\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\\n\"" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " >>> runner.render(foo=900)\n", " __main__\n", " \"\\n...foo... is defined as 900\\n\\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\\n\"" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " >>> runner.run()\n", " __main__\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " >>> runner.run()\n", " __main__\n", " \n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ " >>> with pidgy.util.argv('script --foo 900'):\n", " ... try: runner.cli()\n", " ... except SystemExit: None\n", " __main__\n", " ...foo... is defined as 900\n", " \n", " My document recieved ['script', '--foo', '900'] as arguments.\n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ " >>> with pidgy.util.argv('script --foo 900'):\n", " ... try: runner.cli()\n", " ... except SystemExit: None\n", " __main__\n", " ...foo... is defined as 900\n", " \n", " My document recieved ['script', '--foo', '900'] as arguments.\n", " \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "pidgy 3", "language": "python", "name": "pidgy" }, "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.3" } }, "nbformat": 4, "nbformat_minor": 4 }