Test pidgy.runpidgyΒΆ

[1]:
    import pidgy
import pidgy
[2]:
    >>> dir(pidgy.runpidgy)
    ['Runner', '__all__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__test__', 'ast', 'importlib', 'pidgy', 'render', 'run', 'runpy', 'types']
>>> dir(pidgy.runpidgy)
['Runner', '__all__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '__test__', 'ast', 'importlib', 'pidgy', 'render', 'run', 'runpy', 'types']
[3]:
    foo = None
foo = None
[4]:
The `"templated_document.md"` file has `foo` annotated meaning that it will be recognized as CLI parameter.
The "templated_document.md" file has foo annotated meaning that it will be recognized as CLI parameter.
[5]:
    >>> pidgy.runpidgy.run('templated_document.md')
    __main__
    <module 'templated_document.md' from 'templated_document.md'>
>>> pidgy.runpidgy.run('templated_document.md')
__main__
<module 'templated_document.md' from 'templated_document.md'>
[6]:
    >>> pidgy.runpidgy.render('templated_document.md')
    __main__
    "\n...foo... is defined as 42\n\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\n"
>>> pidgy.runpidgy.render('templated_document.md')
__main__
"\n...foo... is defined as 42\n\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\n"
[7]:
    >>> pidgy.runpidgy.render('templated_document.md', foo=900)
    __main__
    "\n...foo... is defined as 900\n\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\n"
>>> pidgy.runpidgy.render('templated_document.md', foo=900)
__main__
"\n...foo... is defined as 900\n\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\n"
[8]:
    runner = pidgy.runpidgy.Runner('templated_document.md')
runner = pidgy.runpidgy.Runner('templated_document.md')
[9]:
    >>> runner.render(foo=900)
    __main__
    "\n...foo... is defined as 900\n\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\n"
>>> runner.render(foo=900)
__main__
"\n...foo... is defined as 900\n\nMy document recieved ['...__main__.py', 'kernel', 'start', '-f', '...'] as arguments.\n"
[10]:
    >>> runner.run()
    __main__
    <module 'templated_document.md' from 'templated_document.md'>

>>> runner.run()
__main__
<module 'templated_document.md' from 'templated_document.md'>
[11]:
    >>> with pidgy.util.argv('script --foo 900'):
    ...     try: runner.cli()
    ...     except SystemExit: None
    __main__
    ...foo... is defined as 900
    <BLANKLINE>
    My document recieved ['script', '--foo', '900'] as arguments.
    <BLANKLINE>

>>> with pidgy.util.argv('script --foo 900'):
...     try: runner.cli()
...     except SystemExit: None
__main__
...foo... is defined as 900

My document recieved ['script', '--foo', '900'] as arguments.
[ ]: