deleted a bunch of shit...
This commit is contained in:
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
from flask import Flask
|
||||
application = Flask(__name__)
|
||||
@application.route('/')
|
||||
def helloworld():
|
||||
return 'Hello there, world!'
|
||||
@@ -1,76 +0,0 @@
|
||||
# This file must be used with "source bin/activate" *from bash*
|
||||
# you cannot run it directly
|
||||
|
||||
deactivate () {
|
||||
# reset old environment variables
|
||||
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
||||
PATH="${_OLD_VIRTUAL_PATH:-}"
|
||||
export PATH
|
||||
unset _OLD_VIRTUAL_PATH
|
||||
fi
|
||||
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
||||
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
||||
export PYTHONHOME
|
||||
unset _OLD_VIRTUAL_PYTHONHOME
|
||||
fi
|
||||
|
||||
# This should detect bash and zsh, which have a hash command that must
|
||||
# be called to get it to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||
hash -r
|
||||
fi
|
||||
|
||||
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
||||
PS1="${_OLD_VIRTUAL_PS1:-}"
|
||||
export PS1
|
||||
unset _OLD_VIRTUAL_PS1
|
||||
fi
|
||||
|
||||
unset VIRTUAL_ENV
|
||||
if [ ! "$1" = "nondestructive" ] ; then
|
||||
# Self destruct!
|
||||
unset -f deactivate
|
||||
fi
|
||||
}
|
||||
|
||||
# unset irrelevant variables
|
||||
deactivate nondestructive
|
||||
|
||||
VIRTUAL_ENV="/root/projekti/TeraHz/flask/venv"
|
||||
export VIRTUAL_ENV
|
||||
|
||||
_OLD_VIRTUAL_PATH="$PATH"
|
||||
PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
export PATH
|
||||
|
||||
# unset PYTHONHOME if set
|
||||
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
||||
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
||||
if [ -n "${PYTHONHOME:-}" ] ; then
|
||||
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
||||
unset PYTHONHOME
|
||||
fi
|
||||
|
||||
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
||||
_OLD_VIRTUAL_PS1="${PS1:-}"
|
||||
if [ "x(venv) " != x ] ; then
|
||||
PS1="(venv) ${PS1:-}"
|
||||
else
|
||||
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
|
||||
# special case for Aspen magic directories
|
||||
# see http://www.zetadev.com/software/aspen/
|
||||
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
|
||||
else
|
||||
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
|
||||
fi
|
||||
fi
|
||||
export PS1
|
||||
fi
|
||||
|
||||
# This should detect bash and zsh, which have a hash command that must
|
||||
# be called to get it to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||
hash -r
|
||||
fi
|
||||
@@ -1,37 +0,0 @@
|
||||
# This file must be used with "source bin/activate.csh" *from csh*.
|
||||
# You cannot run it directly.
|
||||
# Created by Davide Di Blasi <davidedb@gmail.com>.
|
||||
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
|
||||
|
||||
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
|
||||
|
||||
# Unset irrelevant variables.
|
||||
deactivate nondestructive
|
||||
|
||||
setenv VIRTUAL_ENV "/root/projekti/TeraHz/flask/venv"
|
||||
|
||||
set _OLD_VIRTUAL_PATH="$PATH"
|
||||
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
|
||||
set _OLD_VIRTUAL_PROMPT="$prompt"
|
||||
|
||||
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
|
||||
if ("venv" != "") then
|
||||
set env_name = "venv"
|
||||
else
|
||||
if (`basename "VIRTUAL_ENV"` == "__") then
|
||||
# special case for Aspen magic directories
|
||||
# see http://www.zetadev.com/software/aspen/
|
||||
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
|
||||
else
|
||||
set env_name = `basename "$VIRTUAL_ENV"`
|
||||
endif
|
||||
endif
|
||||
set prompt = "[$env_name] $prompt"
|
||||
unset env_name
|
||||
endif
|
||||
|
||||
alias pydoc python -m pydoc
|
||||
|
||||
rehash
|
||||
@@ -1,75 +0,0 @@
|
||||
# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
|
||||
# you cannot run it directly
|
||||
|
||||
function deactivate -d "Exit virtualenv and return to normal shell environment"
|
||||
# reset old environment variables
|
||||
if test -n "$_OLD_VIRTUAL_PATH"
|
||||
set -gx PATH $_OLD_VIRTUAL_PATH
|
||||
set -e _OLD_VIRTUAL_PATH
|
||||
end
|
||||
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
|
||||
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
|
||||
set -e _OLD_VIRTUAL_PYTHONHOME
|
||||
end
|
||||
|
||||
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
|
||||
functions -e fish_prompt
|
||||
set -e _OLD_FISH_PROMPT_OVERRIDE
|
||||
functions -c _old_fish_prompt fish_prompt
|
||||
functions -e _old_fish_prompt
|
||||
end
|
||||
|
||||
set -e VIRTUAL_ENV
|
||||
if test "$argv[1]" != "nondestructive"
|
||||
# Self destruct!
|
||||
functions -e deactivate
|
||||
end
|
||||
end
|
||||
|
||||
# unset irrelevant variables
|
||||
deactivate nondestructive
|
||||
|
||||
set -gx VIRTUAL_ENV "/root/projekti/TeraHz/flask/venv"
|
||||
|
||||
set -gx _OLD_VIRTUAL_PATH $PATH
|
||||
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
|
||||
|
||||
# unset PYTHONHOME if set
|
||||
if set -q PYTHONHOME
|
||||
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
|
||||
set -e PYTHONHOME
|
||||
end
|
||||
|
||||
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
|
||||
# fish uses a function instead of an env var to generate the prompt.
|
||||
|
||||
# save the current fish_prompt function as the function _old_fish_prompt
|
||||
functions -c fish_prompt _old_fish_prompt
|
||||
|
||||
# with the original prompt function renamed, we can override with our own.
|
||||
function fish_prompt
|
||||
# Save the return status of the last command
|
||||
set -l old_status $status
|
||||
|
||||
# Prompt override?
|
||||
if test -n "(venv) "
|
||||
printf "%s%s" "(venv) " (set_color normal)
|
||||
else
|
||||
# ...Otherwise, prepend env
|
||||
set -l _checkbase (basename "$VIRTUAL_ENV")
|
||||
if test $_checkbase = "__"
|
||||
# special case for Aspen magic directories
|
||||
# see http://www.zetadev.com/software/aspen/
|
||||
printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
|
||||
else
|
||||
printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
|
||||
end
|
||||
end
|
||||
|
||||
# Restore the return status of the previous command.
|
||||
echo "exit $old_status" | .
|
||||
_old_fish_prompt
|
||||
end
|
||||
|
||||
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
|
||||
end
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/root/projekti/TeraHz/flask/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
|
||||
from dotenv.cli import cli
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(cli())
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/root/projekti/TeraHz/flask/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
|
||||
from setuptools.command.easy_install import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/root/projekti/TeraHz/flask/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
|
||||
from setuptools.command.easy_install import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/root/projekti/TeraHz/flask/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
|
||||
from flask.cli import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/root/projekti/TeraHz/flask/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pip._internal import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/root/projekti/TeraHz/flask/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pip._internal import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/root/projekti/TeraHz/flask/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pip._internal import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
@@ -1 +0,0 @@
|
||||
python3
|
||||
@@ -1 +0,0 @@
|
||||
/usr/bin/python3
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/root/projekti/TeraHz/flask/venv/bin/python3
|
||||
# EASY-INSTALL-ENTRY-SCRIPT: 'watchdog==0.9.0','console_scripts','watchmedo'
|
||||
__requires__ = 'watchdog==0.9.0'
|
||||
import re
|
||||
import sys
|
||||
from pkg_resources import load_entry_point
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(
|
||||
load_entry_point('watchdog==0.9.0', 'console_scripts', 'watchmedo')()
|
||||
)
|
||||
@@ -1 +0,0 @@
|
||||
pip
|
||||
@@ -1,39 +0,0 @@
|
||||
Copyright © 2014 by the Pallets team.
|
||||
|
||||
Some rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms of the software as
|
||||
well as documentation, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
----
|
||||
|
||||
Click uses parts of optparse written by Gregory P. Ward and maintained
|
||||
by the Python Software Foundation. This is limited to code in parser.py.
|
||||
|
||||
Copyright © 2001-2006 Gregory P. Ward. All rights reserved.
|
||||
Copyright © 2002-2006 Python Software Foundation. All rights reserved.
|
||||
@@ -1,121 +0,0 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: Click
|
||||
Version: 7.0
|
||||
Summary: Composable command line interface toolkit
|
||||
Home-page: https://palletsprojects.com/p/click/
|
||||
Author: Armin Ronacher
|
||||
Author-email: armin.ronacher@active-4.com
|
||||
Maintainer: Pallets Team
|
||||
Maintainer-email: contact@palletsprojects.com
|
||||
License: BSD
|
||||
Project-URL: Documentation, https://click.palletsprojects.com/
|
||||
Project-URL: Code, https://github.com/pallets/click
|
||||
Project-URL: Issue tracker, https://github.com/pallets/click/issues
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
|
||||
|
||||
\$ click\_
|
||||
==========
|
||||
|
||||
Click is a Python package for creating beautiful command line interfaces
|
||||
in a composable way with as little code as necessary. It's the "Command
|
||||
Line Interface Creation Kit". It's highly configurable but comes with
|
||||
sensible defaults out of the box.
|
||||
|
||||
It aims to make the process of writing command line tools quick and fun
|
||||
while also preventing any frustration caused by the inability to
|
||||
implement an intended CLI API.
|
||||
|
||||
Click in three points:
|
||||
|
||||
- Arbitrary nesting of commands
|
||||
- Automatic help page generation
|
||||
- Supports lazy loading of subcommands at runtime
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
Install and update using `pip`_:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ pip install click
|
||||
|
||||
Click supports Python 3.4 and newer, Python 2.7, and PyPy.
|
||||
|
||||
.. _pip: https://pip.pypa.io/en/stable/quickstart/
|
||||
|
||||
|
||||
A Simple Example
|
||||
----------------
|
||||
|
||||
What does it look like? Here is an example of a simple Click program:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import click
|
||||
|
||||
@click.command()
|
||||
@click.option("--count", default=1, help="Number of greetings.")
|
||||
@click.option("--name", prompt="Your name",
|
||||
help="The person to greet.")
|
||||
def hello(count, name):
|
||||
"""Simple program that greets NAME for a total of COUNT times."""
|
||||
for _ in range(count):
|
||||
click.echo("Hello, %s!" % name)
|
||||
|
||||
if __name__ == '__main__':
|
||||
hello()
|
||||
|
||||
And what it looks like when run:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ python hello.py --count=3
|
||||
Your name: Click
|
||||
Hello, Click!
|
||||
Hello, Click!
|
||||
Hello, Click!
|
||||
|
||||
|
||||
Donate
|
||||
------
|
||||
|
||||
The Pallets organization develops and supports Click and other popular
|
||||
packages. In order to grow the community of contributors and users, and
|
||||
allow the maintainers to devote more time to the projects, `please
|
||||
donate today`_.
|
||||
|
||||
.. _please donate today: https://palletsprojects.com/donate
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* Website: https://palletsprojects.com/p/click/
|
||||
* Documentation: https://click.palletsprojects.com/
|
||||
* License: `BSD <https://github.com/pallets/click/blob/master/LICENSE.rst>`_
|
||||
* Releases: https://pypi.org/project/click/
|
||||
* Code: https://github.com/pallets/click
|
||||
* Issue tracker: https://github.com/pallets/click/issues
|
||||
* Test status:
|
||||
|
||||
* Linux, Mac: https://travis-ci.org/pallets/click
|
||||
* Windows: https://ci.appveyor.com/project/pallets/click
|
||||
|
||||
* Test coverage: https://codecov.io/gh/pallets/click
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
Click-7.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
Click-7.0.dist-info/LICENSE.txt,sha256=4hIxn676T0Wcisk3_chVcECjyrivKTZsoqSNI5AlIlw,1876
|
||||
Click-7.0.dist-info/METADATA,sha256=-r8jeke3Zer4diRvT1MjFZuiJ6yTT_qFP39svLqdaLI,3516
|
||||
Click-7.0.dist-info/RECORD,,
|
||||
Click-7.0.dist-info/WHEEL,sha256=gduuPyBvFJQSQ0zdyxF7k0zynDXbIbvg5ZBHoXum5uk,110
|
||||
Click-7.0.dist-info/top_level.txt,sha256=J1ZQogalYS4pphY_lPECoNMfw0HzTSrZglC4Yfwo4xA,6
|
||||
click/__init__.py,sha256=HjGThQ7tef9kkwCV371TBnrf0SAi6fKfU_jtEnbYTvQ,2789
|
||||
click/__pycache__/__init__.cpython-36.pyc,,
|
||||
click/__pycache__/_bashcomplete.cpython-36.pyc,,
|
||||
click/__pycache__/_compat.cpython-36.pyc,,
|
||||
click/__pycache__/_termui_impl.cpython-36.pyc,,
|
||||
click/__pycache__/_textwrap.cpython-36.pyc,,
|
||||
click/__pycache__/_unicodefun.cpython-36.pyc,,
|
||||
click/__pycache__/_winconsole.cpython-36.pyc,,
|
||||
click/__pycache__/core.cpython-36.pyc,,
|
||||
click/__pycache__/decorators.cpython-36.pyc,,
|
||||
click/__pycache__/exceptions.cpython-36.pyc,,
|
||||
click/__pycache__/formatting.cpython-36.pyc,,
|
||||
click/__pycache__/globals.cpython-36.pyc,,
|
||||
click/__pycache__/parser.cpython-36.pyc,,
|
||||
click/__pycache__/termui.cpython-36.pyc,,
|
||||
click/__pycache__/testing.cpython-36.pyc,,
|
||||
click/__pycache__/types.cpython-36.pyc,,
|
||||
click/__pycache__/utils.cpython-36.pyc,,
|
||||
click/_bashcomplete.py,sha256=iaNUmtxag0YPfxba3TDYCNietiTMQIrvhRLj-H8okFU,11014
|
||||
click/_compat.py,sha256=vYmvoj4opPxo-c-2GMQQjYT_r_QkOKybkfGoeVrt0dA,23399
|
||||
click/_termui_impl.py,sha256=xHmLtOJhKUCVD6168yucJ9fknUJPAMs0eUTPgVUO-GQ,19611
|
||||
click/_textwrap.py,sha256=gwS4m7bdQiJnzaDG8osFcRb-5vn4t4l2qSCy-5csCEc,1198
|
||||
click/_unicodefun.py,sha256=QHy2_5jYlX-36O-JVrTHNnHOqg8tquUR0HmQFev7Ics,4364
|
||||
click/_winconsole.py,sha256=PPWVak8Iikm_gAPsxMrzwsVFCvHgaW3jPaDWZ1JBl3U,8965
|
||||
click/core.py,sha256=q8FLcDZsagBGSRe5Y9Hi_FGvAeZvusNfoO5EkhkSQ8Y,75305
|
||||
click/decorators.py,sha256=idKt6duLUUfAFftrHoREi8MJSd39XW36pUVHthdglwk,11226
|
||||
click/exceptions.py,sha256=CNpAjBAE7qjaV4WChxQeak95e5yUOau8AsvT-8m6wss,7663
|
||||
click/formatting.py,sha256=eh-cypTUAhpI3HD-K4ZpR3vCiURIO62xXvKkR3tNUTM,8889
|
||||
click/globals.py,sha256=oQkou3ZQ5DgrbVM6BwIBirwiqozbjfirzsLGAlLRRdg,1514
|
||||
click/parser.py,sha256=m-nGZz4VwprM42_qtFlWFGo7yRJQxkBlRcZodoH593Y,15510
|
||||
click/termui.py,sha256=o_ZXB2jyvL2Rce7P_bFGq452iyBq9ykJyRApIPMCZO0,23207
|
||||
click/testing.py,sha256=aYGqY_iWLu2p4k7lkuJ6t3fqpf6aPGqTsyLzNY_ngKg,13062
|
||||
click/types.py,sha256=2Q929p-aBP_ZYuMFJqJR-Ipucofv3fmDc5JzBDPmzJU,23287
|
||||
click/utils.py,sha256=6-D0WkAxvv9FkgHXSHwDIv0l9Gdx9Mm6Z5vuKNLIfZI,15763
|
||||
@@ -1,6 +0,0 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.31.1)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
click
|
||||
@@ -1 +0,0 @@
|
||||
pip
|
||||
@@ -1,31 +0,0 @@
|
||||
Copyright © 2010 by the Pallets team.
|
||||
|
||||
Some rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms of the software as
|
||||
well as documentation, with or without modification, are permitted
|
||||
provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
@@ -1,130 +0,0 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: Flask
|
||||
Version: 1.0.2
|
||||
Summary: A simple framework for building complex web applications.
|
||||
Home-page: https://www.palletsprojects.com/p/flask/
|
||||
Author: Armin Ronacher
|
||||
Author-email: armin.ronacher@active-4.com
|
||||
Maintainer: Pallets team
|
||||
Maintainer-email: contact@palletsprojects.com
|
||||
License: BSD
|
||||
Project-URL: Documentation, http://flask.pocoo.org/docs/
|
||||
Project-URL: Code, https://github.com/pallets/flask
|
||||
Project-URL: Issue tracker, https://github.com/pallets/flask/issues
|
||||
Platform: any
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Environment :: Web Environment
|
||||
Classifier: Framework :: Flask
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
|
||||
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Provides-Extra: dev
|
||||
Provides-Extra: docs
|
||||
Provides-Extra: dotenv
|
||||
Requires-Dist: Werkzeug (>=0.14)
|
||||
Requires-Dist: Jinja2 (>=2.10)
|
||||
Requires-Dist: itsdangerous (>=0.24)
|
||||
Requires-Dist: click (>=5.1)
|
||||
Provides-Extra: dev
|
||||
Requires-Dist: pytest (>=3); extra == 'dev'
|
||||
Requires-Dist: coverage; extra == 'dev'
|
||||
Requires-Dist: tox; extra == 'dev'
|
||||
Requires-Dist: sphinx; extra == 'dev'
|
||||
Requires-Dist: pallets-sphinx-themes; extra == 'dev'
|
||||
Requires-Dist: sphinxcontrib-log-cabinet; extra == 'dev'
|
||||
Provides-Extra: docs
|
||||
Requires-Dist: sphinx; extra == 'docs'
|
||||
Requires-Dist: pallets-sphinx-themes; extra == 'docs'
|
||||
Requires-Dist: sphinxcontrib-log-cabinet; extra == 'docs'
|
||||
Provides-Extra: dotenv
|
||||
Requires-Dist: python-dotenv; extra == 'dotenv'
|
||||
|
||||
Flask
|
||||
=====
|
||||
|
||||
Flask is a lightweight `WSGI`_ web application framework. It is designed
|
||||
to make getting started quick and easy, with the ability to scale up to
|
||||
complex applications. It began as a simple wrapper around `Werkzeug`_
|
||||
and `Jinja`_ and has become one of the most popular Python web
|
||||
application frameworks.
|
||||
|
||||
Flask offers suggestions, but doesn't enforce any dependencies or
|
||||
project layout. It is up to the developer to choose the tools and
|
||||
libraries they want to use. There are many extensions provided by the
|
||||
community that make adding new functionality easy.
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
Install and update using `pip`_:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
pip install -U Flask
|
||||
|
||||
|
||||
A Simple Example
|
||||
----------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def hello():
|
||||
return 'Hello, World!'
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ FLASK_APP=hello.py flask run
|
||||
* Serving Flask app "hello"
|
||||
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
||||
|
||||
|
||||
Donate
|
||||
------
|
||||
|
||||
The Pallets organization develops and supports Flask and the libraries
|
||||
it uses. In order to grow the community of contributors and users, and
|
||||
allow the maintainers to devote more time to the projects, `please
|
||||
donate today`_.
|
||||
|
||||
.. _please donate today: https://psfmember.org/civicrm/contribute/transact?reset=1&id=20
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* Website: https://www.palletsprojects.com/p/flask/
|
||||
* Documentation: http://flask.pocoo.org/docs/
|
||||
* License: `BSD <https://github.com/pallets/flask/blob/master/LICENSE>`_
|
||||
* Releases: https://pypi.org/project/Flask/
|
||||
* Code: https://github.com/pallets/flask
|
||||
* Issue tracker: https://github.com/pallets/flask/issues
|
||||
* Test status:
|
||||
|
||||
* Linux, Mac: https://travis-ci.org/pallets/flask
|
||||
* Windows: https://ci.appveyor.com/project/pallets/flask
|
||||
|
||||
* Test coverage: https://codecov.io/gh/pallets/flask
|
||||
|
||||
.. _WSGI: https://wsgi.readthedocs.io
|
||||
.. _Werkzeug: https://www.palletsprojects.com/p/werkzeug/
|
||||
.. _Jinja: https://www.palletsprojects.com/p/jinja/
|
||||
.. _pip: https://pip.pypa.io/en/stable/quickstart/
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
../../../bin/flask,sha256=PJpKemt9ycjSY85Fc33FpXJqiYyDexlc2Z9ziSH4wPo,239
|
||||
Flask-1.0.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
Flask-1.0.2.dist-info/LICENSE.txt,sha256=ziEXA3AIuaiUn1qe4cd1XxCESWTYrk4TjN7Qb06J3l8,1575
|
||||
Flask-1.0.2.dist-info/METADATA,sha256=iA5tiNWzTtgCVe80aTZGNWsckj853fJyfvHs9U-WZRk,4182
|
||||
Flask-1.0.2.dist-info/RECORD,,
|
||||
Flask-1.0.2.dist-info/WHEEL,sha256=J3CsTk7Mf2JNUyhImI-mjX-fmI4oDjyiXgWT4qgZiCE,110
|
||||
Flask-1.0.2.dist-info/entry_points.txt,sha256=gBLA1aKg0OYR8AhbAfg8lnburHtKcgJLDU52BBctN0k,42
|
||||
Flask-1.0.2.dist-info/top_level.txt,sha256=dvi65F6AeGWVU0TBpYiC04yM60-FX1gJFkK31IKQr5c,6
|
||||
flask/__init__.py,sha256=qq8lK6QQbxJALf1igz7qsvUwOTAoKvFGfdLm7jPNsso,1673
|
||||
flask/__main__.py,sha256=pgIXrHhxM5MAMvgzAqWpw_t6AXZ1zG38us4JRgJKtxk,291
|
||||
flask/__pycache__/__init__.cpython-36.pyc,,
|
||||
flask/__pycache__/__main__.cpython-36.pyc,,
|
||||
flask/__pycache__/_compat.cpython-36.pyc,,
|
||||
flask/__pycache__/app.cpython-36.pyc,,
|
||||
flask/__pycache__/blueprints.cpython-36.pyc,,
|
||||
flask/__pycache__/cli.cpython-36.pyc,,
|
||||
flask/__pycache__/config.cpython-36.pyc,,
|
||||
flask/__pycache__/ctx.cpython-36.pyc,,
|
||||
flask/__pycache__/debughelpers.cpython-36.pyc,,
|
||||
flask/__pycache__/globals.cpython-36.pyc,,
|
||||
flask/__pycache__/helpers.cpython-36.pyc,,
|
||||
flask/__pycache__/logging.cpython-36.pyc,,
|
||||
flask/__pycache__/sessions.cpython-36.pyc,,
|
||||
flask/__pycache__/signals.cpython-36.pyc,,
|
||||
flask/__pycache__/templating.cpython-36.pyc,,
|
||||
flask/__pycache__/testing.cpython-36.pyc,,
|
||||
flask/__pycache__/views.cpython-36.pyc,,
|
||||
flask/__pycache__/wrappers.cpython-36.pyc,,
|
||||
flask/_compat.py,sha256=UDFGhosh6mOdNB-4evKPuneHum1OpcAlwTNJCRm0irQ,2892
|
||||
flask/app.py,sha256=ahpe3T8w98rQd_Er5d7uDxK57S1nnqGQx3V3hirBovU,94147
|
||||
flask/blueprints.py,sha256=Cyhl_x99tgwqEZPtNDJUFneAfVJxWfEU4bQA7zWS6VU,18331
|
||||
flask/cli.py,sha256=30QYAO10Do9LbZYCLgfI_xhKjASdLopL8wKKVUGS2oA,29442
|
||||
flask/config.py,sha256=kznUhj4DLYxsTF_4kfDG8GEHto1oZG_kqblyrLFtpqQ,9951
|
||||
flask/ctx.py,sha256=leFzS9fzmo0uaLCdxpHc5_iiJZ1H0X_Ig4yPCOvT--g,16224
|
||||
flask/debughelpers.py,sha256=1ceC-UyqZTd4KsJkf0OObHPsVt5R3T6vnmYhiWBjV-w,6479
|
||||
flask/globals.py,sha256=pGg72QW_-4xUfsI33I5L_y76c21AeqfSqXDcbd8wvXU,1649
|
||||
flask/helpers.py,sha256=YCl8D1plTO1evEYP4KIgaY3H8Izww5j4EdgRJ89oHTw,40106
|
||||
flask/json/__init__.py,sha256=Ns1Hj805XIxuBMh2z0dYnMVfb_KUgLzDmP3WoUYaPhw,10729
|
||||
flask/json/__pycache__/__init__.cpython-36.pyc,,
|
||||
flask/json/__pycache__/tag.cpython-36.pyc,,
|
||||
flask/json/tag.py,sha256=9ehzrmt5k7hxf7ZEK0NOs3swvQyU9fWNe-pnYe69N60,8223
|
||||
flask/logging.py,sha256=qV9h0vt7NIRkKM9OHDWndzO61E5CeBMlqPJyTt-W2Wc,2231
|
||||
flask/sessions.py,sha256=2XHV4ASREhSEZ8bsPQW6pNVNuFtbR-04BzfKg0AfvHo,14452
|
||||
flask/signals.py,sha256=BGQbVyCYXnzKK2DVCzppKFyWN1qmrtW1QMAYUs-1Nr8,2211
|
||||
flask/templating.py,sha256=FDfWMbpgpC3qObW8GGXRAVrkHFF8K4CHOJymB1wvULI,4914
|
||||
flask/testing.py,sha256=XD3gWNvLUV8dqVHwKd9tZzsj81fSHtjOphQ1wTNtlMs,9379
|
||||
flask/views.py,sha256=Wy-_WkUVtCfE2zCXYeJehNgHuEtviE4v3HYfJ--MpbY,5733
|
||||
flask/wrappers.py,sha256=1Z9hF5-hXQajn_58XITQFRY8efv3Vy3uZ0avBfZu6XI,7511
|
||||
@@ -1,6 +0,0 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.31.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[console_scripts]
|
||||
flask = flask.cli:main
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
flask
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
Jinja2
|
||||
~~~~~~
|
||||
|
||||
Jinja2 is a template engine written in pure Python. It provides a
|
||||
`Django`_ inspired non-XML syntax but supports inline expressions and
|
||||
an optional `sandboxed`_ environment.
|
||||
|
||||
Nutshell
|
||||
--------
|
||||
|
||||
Here a small example of a Jinja template::
|
||||
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}Memberlist{% endblock %}
|
||||
{% block content %}
|
||||
<ul>
|
||||
{% for user in users %}
|
||||
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
Philosophy
|
||||
----------
|
||||
|
||||
Application logic is for the controller but don't try to make the life
|
||||
for the template designer too hard by giving him too few functionality.
|
||||
|
||||
For more informations visit the new `Jinja2 webpage`_ and `documentation`_.
|
||||
|
||||
.. _sandboxed: https://en.wikipedia.org/wiki/Sandbox_(computer_security)
|
||||
.. _Django: https://www.djangoproject.com/
|
||||
.. _Jinja2 webpage: http://jinja.pocoo.org/
|
||||
.. _documentation: http://jinja.pocoo.org/2/documentation/
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
pip
|
||||
@@ -1,31 +0,0 @@
|
||||
Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details.
|
||||
|
||||
Some rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* The names of the contributors may not be used to endorse or
|
||||
promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,68 +0,0 @@
|
||||
Metadata-Version: 2.0
|
||||
Name: Jinja2
|
||||
Version: 2.10
|
||||
Summary: A small but fast and easy to use stand-alone template engine written in pure python.
|
||||
Home-page: http://jinja.pocoo.org/
|
||||
Author: Armin Ronacher
|
||||
Author-email: armin.ronacher@active-4.com
|
||||
License: BSD
|
||||
Description-Content-Type: UNKNOWN
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Environment :: Web Environment
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Classifier: Topic :: Text Processing :: Markup :: HTML
|
||||
Requires-Dist: MarkupSafe (>=0.23)
|
||||
Provides-Extra: i18n
|
||||
Requires-Dist: Babel (>=0.8); extra == 'i18n'
|
||||
|
||||
|
||||
Jinja2
|
||||
~~~~~~
|
||||
|
||||
Jinja2 is a template engine written in pure Python. It provides a
|
||||
`Django`_ inspired non-XML syntax but supports inline expressions and
|
||||
an optional `sandboxed`_ environment.
|
||||
|
||||
Nutshell
|
||||
--------
|
||||
|
||||
Here a small example of a Jinja template::
|
||||
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}Memberlist{% endblock %}
|
||||
{% block content %}
|
||||
<ul>
|
||||
{% for user in users %}
|
||||
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
Philosophy
|
||||
----------
|
||||
|
||||
Application logic is for the controller but don't try to make the life
|
||||
for the template designer too hard by giving him too few functionality.
|
||||
|
||||
For more informations visit the new `Jinja2 webpage`_ and `documentation`_.
|
||||
|
||||
.. _sandboxed: https://en.wikipedia.org/wiki/Sandbox_(computer_security)
|
||||
.. _Django: https://www.djangoproject.com/
|
||||
.. _Jinja2 webpage: http://jinja.pocoo.org/
|
||||
.. _documentation: http://jinja.pocoo.org/2/documentation/
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
Jinja2-2.10.dist-info/DESCRIPTION.rst,sha256=b5ckFDoM7vVtz_mAsJD4OPteFKCqE7beu353g4COoYI,978
|
||||
Jinja2-2.10.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
Jinja2-2.10.dist-info/LICENSE.txt,sha256=JvzUNv3Io51EiWrAPm8d_SXjhJnEjyDYvB3Tvwqqils,1554
|
||||
Jinja2-2.10.dist-info/METADATA,sha256=18EgU8zR6-av-0-5y_gXebzK4GnBB_76lALUsl-6QHM,2258
|
||||
Jinja2-2.10.dist-info/RECORD,,
|
||||
Jinja2-2.10.dist-info/WHEEL,sha256=kdsN-5OJAZIiHN-iO4Rhl82KyS0bDWf4uBwMbkNafr8,110
|
||||
Jinja2-2.10.dist-info/entry_points.txt,sha256=NdzVcOrqyNyKDxD09aERj__3bFx2paZhizFDsKmVhiA,72
|
||||
Jinja2-2.10.dist-info/metadata.json,sha256=NPUJ9TMBxVQAv_kTJzvU8HwmP-4XZvbK9mz6_4YUVl4,1473
|
||||
Jinja2-2.10.dist-info/top_level.txt,sha256=PkeVWtLb3-CqjWi1fO29OCbj55EhX_chhKrCdrVe_zs,7
|
||||
jinja2/__init__.py,sha256=xJHjaMoy51_KXn1wf0cysH6tUUifUxZCwSOfcJGEYZw,2614
|
||||
jinja2/__pycache__/__init__.cpython-36.pyc,,
|
||||
jinja2/__pycache__/_compat.cpython-36.pyc,,
|
||||
jinja2/__pycache__/_identifier.cpython-36.pyc,,
|
||||
jinja2/__pycache__/asyncfilters.cpython-36.pyc,,
|
||||
jinja2/__pycache__/asyncsupport.cpython-36.pyc,,
|
||||
jinja2/__pycache__/bccache.cpython-36.pyc,,
|
||||
jinja2/__pycache__/compiler.cpython-36.pyc,,
|
||||
jinja2/__pycache__/constants.cpython-36.pyc,,
|
||||
jinja2/__pycache__/debug.cpython-36.pyc,,
|
||||
jinja2/__pycache__/defaults.cpython-36.pyc,,
|
||||
jinja2/__pycache__/environment.cpython-36.pyc,,
|
||||
jinja2/__pycache__/exceptions.cpython-36.pyc,,
|
||||
jinja2/__pycache__/ext.cpython-36.pyc,,
|
||||
jinja2/__pycache__/filters.cpython-36.pyc,,
|
||||
jinja2/__pycache__/idtracking.cpython-36.pyc,,
|
||||
jinja2/__pycache__/lexer.cpython-36.pyc,,
|
||||
jinja2/__pycache__/loaders.cpython-36.pyc,,
|
||||
jinja2/__pycache__/meta.cpython-36.pyc,,
|
||||
jinja2/__pycache__/nativetypes.cpython-36.pyc,,
|
||||
jinja2/__pycache__/nodes.cpython-36.pyc,,
|
||||
jinja2/__pycache__/optimizer.cpython-36.pyc,,
|
||||
jinja2/__pycache__/parser.cpython-36.pyc,,
|
||||
jinja2/__pycache__/runtime.cpython-36.pyc,,
|
||||
jinja2/__pycache__/sandbox.cpython-36.pyc,,
|
||||
jinja2/__pycache__/tests.cpython-36.pyc,,
|
||||
jinja2/__pycache__/utils.cpython-36.pyc,,
|
||||
jinja2/__pycache__/visitor.cpython-36.pyc,,
|
||||
jinja2/_compat.py,sha256=xP60CE5Qr8FTYcDE1f54tbZLKGvMwYml4-8T7Q4KG9k,2596
|
||||
jinja2/_identifier.py,sha256=W1QBSY-iJsyt6oR_nKSuNNCzV95vLIOYgUNPUI1d5gU,1726
|
||||
jinja2/asyncfilters.py,sha256=cTDPvrS8Hp_IkwsZ1m9af_lr5nHysw7uTa5gV0NmZVE,4144
|
||||
jinja2/asyncsupport.py,sha256=UErQ3YlTLaSjFb94P4MVn08-aVD9jJxty2JVfMRb-1M,7878
|
||||
jinja2/bccache.py,sha256=nQldx0ZRYANMyfvOihRoYFKSlUdd5vJkS7BjxNwlOZM,12794
|
||||
jinja2/compiler.py,sha256=BqC5U6JxObSRhblyT_a6Tp5GtEU5z3US1a4jLQaxxgo,65386
|
||||
jinja2/constants.py,sha256=uwwV8ZUhHhacAuz5PTwckfsbqBaqM7aKfyJL7kGX5YQ,1626
|
||||
jinja2/debug.py,sha256=WTVeUFGUa4v6ReCsYv-iVPa3pkNB75OinJt3PfxNdXs,12045
|
||||
jinja2/defaults.py,sha256=Em-95hmsJxIenDCZFB1YSvf9CNhe9rBmytN3yUrBcWA,1400
|
||||
jinja2/environment.py,sha256=VnkAkqw8JbjZct4tAyHlpBrka2vqB-Z58RAP-32P1ZY,50849
|
||||
jinja2/exceptions.py,sha256=_Rj-NVi98Q6AiEjYQOsP8dEIdu5AlmRHzcSNOPdWix4,4428
|
||||
jinja2/ext.py,sha256=atMQydEC86tN1zUsdQiHw5L5cF62nDbqGue25Yiu3N4,24500
|
||||
jinja2/filters.py,sha256=yOAJk0MsH-_gEC0i0U6NweVQhbtYaC-uE8xswHFLF4w,36528
|
||||
jinja2/idtracking.py,sha256=2GbDSzIvGArEBGLkovLkqEfmYxmWsEf8c3QZwM4uNsw,9197
|
||||
jinja2/lexer.py,sha256=ySEPoXd1g7wRjsuw23uimS6nkGN5aqrYwcOKxCaVMBQ,28559
|
||||
jinja2/loaders.py,sha256=xiTuURKAEObyym0nU8PCIXu_Qp8fn0AJ5oIADUUm-5Q,17382
|
||||
jinja2/meta.py,sha256=fmKHxkmZYAOm9QyWWy8EMd6eefAIh234rkBMW2X4ZR8,4340
|
||||
jinja2/nativetypes.py,sha256=_sJhS8f-8Q0QMIC0dm1YEdLyxEyoO-kch8qOL5xUDfE,7308
|
||||
jinja2/nodes.py,sha256=L10L_nQDfubLhO3XjpF9qz46FSh2clL-3e49ogVlMmA,30853
|
||||
jinja2/optimizer.py,sha256=MsdlFACJ0FRdPtjmCAdt7JQ9SGrXFaDNUaslsWQaG3M,1722
|
||||
jinja2/parser.py,sha256=lPzTEbcpTRBLw8ii6OYyExHeAhaZLMA05Hpv4ll3ULk,35875
|
||||
jinja2/runtime.py,sha256=DHdD38Pq8gj7uWQC5usJyWFoNWL317A9AvXOW_CLB34,27755
|
||||
jinja2/sandbox.py,sha256=TVyZHlNqqTzsv9fv2NvJNmSdWRHTguhyMHdxjWms32U,16708
|
||||
jinja2/tests.py,sha256=iJQLwbapZr-EKquTG_fVOVdwHUUKf3SX9eNkjQDF8oU,4237
|
||||
jinja2/utils.py,sha256=q24VupGZotQ-uOyrJxCaXtDWhZC1RgsQG7kcdmjck2Q,20629
|
||||
jinja2/visitor.py,sha256=JD1H1cANA29JcntFfN5fPyqQxB4bI4wC00BzZa-XHks,3316
|
||||
@@ -1,6 +0,0 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.30.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
[babel.extractors]
|
||||
jinja2 = jinja2.ext:babel_extract[i18n]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"classifiers": ["Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup :: HTML"], "description_content_type": "UNKNOWN", "extensions": {"python.details": {"contacts": [{"email": "armin.ronacher@active-4.com", "name": "Armin Ronacher", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst", "license": "LICENSE.txt"}, "project_urls": {"Home": "http://jinja.pocoo.org/"}}, "python.exports": {"babel.extractors": {"jinja2": "jinja2.ext:babel_extract [i18n]"}}}, "extras": ["i18n"], "generator": "bdist_wheel (0.30.0)", "license": "BSD", "metadata_version": "2.0", "name": "Jinja2", "run_requires": [{"extra": "i18n", "requires": ["Babel (>=0.8)"]}, {"requires": ["MarkupSafe (>=0.23)"]}], "summary": "A small but fast and easy to use stand-alone template engine written in pure python.", "version": "2.10"}
|
||||
@@ -1 +0,0 @@
|
||||
jinja2
|
||||
@@ -1 +0,0 @@
|
||||
pip
|
||||
@@ -1,33 +0,0 @@
|
||||
`BSD 3-Clause <https://opensource.org/licenses/BSD-3-Clause>`_
|
||||
|
||||
Copyright © 2010 by the Pallets team.
|
||||
|
||||
Some rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
@@ -1,103 +0,0 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: MarkupSafe
|
||||
Version: 1.1.0
|
||||
Summary: Safely add untrusted strings to HTML/XML markup.
|
||||
Home-page: https://www.palletsprojects.com/p/markupsafe/
|
||||
Author: Armin Ronacher
|
||||
Author-email: armin.ronacher@active-4.com
|
||||
Maintainer: Pallets Team
|
||||
Maintainer-email: contact@palletsprojects.com
|
||||
License: BSD
|
||||
Project-URL: Documentation, https://markupsafe.palletsprojects.com/
|
||||
Project-URL: Code, https://github.com/pallets/markupsafe
|
||||
Project-URL: Issue tracker, https://github.com/pallets/markupsafe/issues
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Environment :: Web Environment
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Classifier: Topic :: Text Processing :: Markup :: HTML
|
||||
Requires-Python: >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
|
||||
|
||||
MarkupSafe
|
||||
==========
|
||||
|
||||
MarkupSafe implements a text object that escapes characters so it is
|
||||
safe to use in HTML and XML. Characters that have special meanings are
|
||||
replaced so that they display as the actual characters. This mitigates
|
||||
injection attacks, meaning untrusted user input can safely be displayed
|
||||
on a page.
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
Install and update using `pip`_:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
pip install -U MarkupSafe
|
||||
|
||||
.. _pip: https://pip.pypa.io/en/stable/quickstart/
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from markupsafe import Markup, escape
|
||||
>>> # escape replaces special characters and wraps in Markup
|
||||
>>> escape('<script>alert(document.cookie);</script>')
|
||||
Markup(u'<script>alert(document.cookie);</script>')
|
||||
>>> # wrap in Markup to mark text "safe" and prevent escaping
|
||||
>>> Markup('<strong>Hello</strong>')
|
||||
Markup('<strong>hello</strong>')
|
||||
>>> escape(Markup('<strong>Hello</strong>'))
|
||||
Markup('<strong>hello</strong>')
|
||||
>>> # Markup is a text subclass (str on Python 3, unicode on Python 2)
|
||||
>>> # methods and operators escape their arguments
|
||||
>>> template = Markup("Hello <em>%s</em>")
|
||||
>>> template % '"World"'
|
||||
Markup('Hello <em>"World"</em>')
|
||||
|
||||
|
||||
Donate
|
||||
------
|
||||
|
||||
The Pallets organization develops and supports MarkupSafe and other
|
||||
libraries that use it. In order to grow the community of contributors
|
||||
and users, and allow the maintainers to devote more time to the
|
||||
projects, `please donate today`_.
|
||||
|
||||
.. _please donate today: https://psfmember.org/civicrm/contribute/transact?reset=1&id=20
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* Website: https://www.palletsprojects.com/p/markupsafe/
|
||||
* Documentation: https://markupsafe.palletsprojects.com/
|
||||
* License: `BSD <https://github.com/pallets/markupsafe/blob/master/LICENSE.rst>`_
|
||||
* Releases: https://pypi.org/project/MarkupSafe/
|
||||
* Code: https://github.com/pallets/markupsafe
|
||||
* Issue tracker: https://github.com/pallets/markupsafe/issues
|
||||
* Test status:
|
||||
|
||||
* Linux, Mac: https://travis-ci.org/pallets/markupsafe
|
||||
* Windows: https://ci.appveyor.com/project/pallets/markupsafe
|
||||
|
||||
* Test coverage: https://codecov.io/gh/pallets/markupsafe
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
MarkupSafe-1.1.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
MarkupSafe-1.1.0.dist-info/LICENSE.txt,sha256=7V249lpOdvRv2m6SF9gCDtq_nsg8tFpdeTdsWWM_g9M,1614
|
||||
MarkupSafe-1.1.0.dist-info/METADATA,sha256=usFnBges7tmAH4_Yt5Ypb8Bco4R9uLUdD0V6YHbvhLw,3585
|
||||
MarkupSafe-1.1.0.dist-info/RECORD,,
|
||||
MarkupSafe-1.1.0.dist-info/WHEEL,sha256=d2ILPScH-y2UwGxsW1PeA2TT-KW0Git4AJ6LeOK8sQo,109
|
||||
MarkupSafe-1.1.0.dist-info/top_level.txt,sha256=qy0Plje5IJuvsCBjejJyhDCjEAdcDLK_2agVcex8Z6U,11
|
||||
markupsafe/__init__.py,sha256=T5J4pS7LRx1xRqfV3xz-QN_D9pSmfVDJnTrc2cTO4Ro,10164
|
||||
markupsafe/__pycache__/__init__.cpython-36.pyc,,
|
||||
markupsafe/__pycache__/_compat.cpython-36.pyc,,
|
||||
markupsafe/__pycache__/_constants.cpython-36.pyc,,
|
||||
markupsafe/__pycache__/_native.cpython-36.pyc,,
|
||||
markupsafe/_compat.py,sha256=3oSvQpEFzsJ29NKVy-Fqk6ZlRxmlCB5k0G21aN0zNtQ,596
|
||||
markupsafe/_constants.py,sha256=ueEz1Jxdw5TKWBbhPr4Ad_2L2MSEh73AYiYe4l3cZy4,4728
|
||||
markupsafe/_native.py,sha256=fUrjjbRXIpHM-8l9QXFJ2xg5rv_48U2aN99plyL0kfs,1911
|
||||
markupsafe/_speedups.c,sha256=VfElhhq9oulHEd2wBZ2MX9A80r4jFovsVGQD2zxmVk0,9883
|
||||
markupsafe/_speedups.cpython-36m-x86_64-linux-gnu.so,sha256=BS7m4DA4L7J_sXAEFkmQeW3HJStGrC1yXYRifVOaTvc,38555
|
||||
@@ -1,5 +0,0 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.31.1)
|
||||
Root-Is-Purelib: false
|
||||
Tag: cp36-cp36m-manylinux1_x86_64
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
markupsafe
|
||||
@@ -1,33 +0,0 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: PyYAML
|
||||
Version: 3.13
|
||||
Summary: YAML parser and emitter for Python
|
||||
Home-page: http://pyyaml.org/wiki/PyYAML
|
||||
Author: Kirill Simonov
|
||||
Author-email: xi@resolvent.net
|
||||
License: MIT
|
||||
Download-URL: http://pyyaml.org/download/pyyaml/PyYAML-3.13.tar.gz
|
||||
Description: YAML is a data serialization format designed for human readability
|
||||
and interaction with scripting languages. PyYAML is a YAML parser
|
||||
and emitter for Python.
|
||||
|
||||
PyYAML features a complete YAML 1.1 parser, Unicode support, pickle
|
||||
support, capable extension API, and sensible error messages. PyYAML
|
||||
supports standard YAML tags and provides Python-specific tags that
|
||||
allow to represent an arbitrary Python object.
|
||||
|
||||
PyYAML is applicable for a broad range of tasks from complex
|
||||
configuration files to object serialization and persistance.
|
||||
Platform: Any
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Classifier: Topic :: Text Processing :: Markup
|
||||
@@ -1,28 +0,0 @@
|
||||
README
|
||||
setup.cfg
|
||||
setup.py
|
||||
ext/_yaml.c
|
||||
ext/_yaml.h
|
||||
ext/_yaml.pxd
|
||||
ext/_yaml.pyx
|
||||
lib3/PyYAML.egg-info/PKG-INFO
|
||||
lib3/PyYAML.egg-info/SOURCES.txt
|
||||
lib3/PyYAML.egg-info/dependency_links.txt
|
||||
lib3/PyYAML.egg-info/top_level.txt
|
||||
lib3/yaml/__init__.py
|
||||
lib3/yaml/composer.py
|
||||
lib3/yaml/constructor.py
|
||||
lib3/yaml/cyaml.py
|
||||
lib3/yaml/dumper.py
|
||||
lib3/yaml/emitter.py
|
||||
lib3/yaml/error.py
|
||||
lib3/yaml/events.py
|
||||
lib3/yaml/loader.py
|
||||
lib3/yaml/nodes.py
|
||||
lib3/yaml/parser.py
|
||||
lib3/yaml/reader.py
|
||||
lib3/yaml/representer.py
|
||||
lib3/yaml/resolver.py
|
||||
lib3/yaml/scanner.py
|
||||
lib3/yaml/serializer.py
|
||||
lib3/yaml/tokens.py
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
../yaml/__init__.py
|
||||
../yaml/__pycache__/__init__.cpython-36.pyc
|
||||
../yaml/__pycache__/composer.cpython-36.pyc
|
||||
../yaml/__pycache__/constructor.cpython-36.pyc
|
||||
../yaml/__pycache__/cyaml.cpython-36.pyc
|
||||
../yaml/__pycache__/dumper.cpython-36.pyc
|
||||
../yaml/__pycache__/emitter.cpython-36.pyc
|
||||
../yaml/__pycache__/error.cpython-36.pyc
|
||||
../yaml/__pycache__/events.cpython-36.pyc
|
||||
../yaml/__pycache__/loader.cpython-36.pyc
|
||||
../yaml/__pycache__/nodes.cpython-36.pyc
|
||||
../yaml/__pycache__/parser.cpython-36.pyc
|
||||
../yaml/__pycache__/reader.cpython-36.pyc
|
||||
../yaml/__pycache__/representer.cpython-36.pyc
|
||||
../yaml/__pycache__/resolver.cpython-36.pyc
|
||||
../yaml/__pycache__/scanner.cpython-36.pyc
|
||||
../yaml/__pycache__/serializer.cpython-36.pyc
|
||||
../yaml/__pycache__/tokens.cpython-36.pyc
|
||||
../yaml/composer.py
|
||||
../yaml/constructor.py
|
||||
../yaml/cyaml.py
|
||||
../yaml/dumper.py
|
||||
../yaml/emitter.py
|
||||
../yaml/error.py
|
||||
../yaml/events.py
|
||||
../yaml/loader.py
|
||||
../yaml/nodes.py
|
||||
../yaml/parser.py
|
||||
../yaml/reader.py
|
||||
../yaml/representer.py
|
||||
../yaml/resolver.py
|
||||
../yaml/scanner.py
|
||||
../yaml/serializer.py
|
||||
../yaml/tokens.py
|
||||
PKG-INFO
|
||||
SOURCES.txt
|
||||
dependency_links.txt
|
||||
top_level.txt
|
||||
@@ -1,2 +0,0 @@
|
||||
_yaml
|
||||
yaml
|
||||
@@ -1,80 +0,0 @@
|
||||
Werkzeug
|
||||
========
|
||||
|
||||
Werkzeug is a comprehensive `WSGI`_ web application library. It began as
|
||||
a simple collection of various utilities for WSGI applications and has
|
||||
become one of the most advanced WSGI utility libraries.
|
||||
|
||||
It includes:
|
||||
|
||||
* An interactive debugger that allows inspecting stack traces and source
|
||||
code in the browser with an interactive interpreter for any frame in
|
||||
the stack.
|
||||
* A full-featured request object with objects to interact with headers,
|
||||
query args, form data, files, and cookies.
|
||||
* A response object that can wrap other WSGI applications and handle
|
||||
streaming data.
|
||||
* A routing system for matching URLs to endpoints and generating URLs
|
||||
for endpoints, with an extensible system for capturing variables from
|
||||
URLs.
|
||||
* HTTP utilities to handle entity tags, cache control, dates, user
|
||||
agents, cookies, files, and more.
|
||||
* A threaded WSGI server for use while developing applications locally.
|
||||
* A test client for simulating HTTP requests during testing without
|
||||
requiring running a server.
|
||||
|
||||
Werkzeug is Unicode aware and doesn't enforce any dependencies. It is up
|
||||
to the developer to choose a template engine, database adapter, and even
|
||||
how to handle requests. It can be used to build all sorts of end user
|
||||
applications such as blogs, wikis, or bulletin boards.
|
||||
|
||||
`Flask`_ wraps Werkzeug, using it to handle the details of WSGI while
|
||||
providing more structure and patterns for defining powerful
|
||||
applications.
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
Install and update using `pip`_:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
pip install -U Werkzeug
|
||||
|
||||
|
||||
A Simple Example
|
||||
----------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from werkzeug.wrappers import Request, Response
|
||||
|
||||
@Request.application
|
||||
def application(request):
|
||||
return Response('Hello, World!')
|
||||
|
||||
if __name__ == '__main__':
|
||||
from werkzeug.serving import run_simple
|
||||
run_simple('localhost', 4000, application)
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* Website: https://www.palletsprojects.com/p/werkzeug/
|
||||
* Releases: https://pypi.org/project/Werkzeug/
|
||||
* Code: https://github.com/pallets/werkzeug
|
||||
* Issue tracker: https://github.com/pallets/werkzeug/issues
|
||||
* Test status:
|
||||
|
||||
* Linux, Mac: https://travis-ci.org/pallets/werkzeug
|
||||
* Windows: https://ci.appveyor.com/project/davidism/werkzeug
|
||||
|
||||
* Test coverage: https://codecov.io/gh/pallets/werkzeug
|
||||
|
||||
.. _WSGI: https://wsgi.readthedocs.io/en/latest/
|
||||
.. _Flask: https://www.palletsprojects.com/p/flask/
|
||||
.. _pip: https://pip.pypa.io/en/stable/quickstart/
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
pip
|
||||
@@ -1,31 +0,0 @@
|
||||
Copyright © 2007 by the Pallets team.
|
||||
|
||||
Some rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
@@ -1,116 +0,0 @@
|
||||
Metadata-Version: 2.0
|
||||
Name: Werkzeug
|
||||
Version: 0.14.1
|
||||
Summary: The comprehensive WSGI web application library.
|
||||
Home-page: https://www.palletsprojects.org/p/werkzeug/
|
||||
Author: Armin Ronacher
|
||||
Author-email: armin.ronacher@active-4.com
|
||||
License: BSD
|
||||
Description-Content-Type: UNKNOWN
|
||||
Platform: any
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Environment :: Web Environment
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: BSD License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Provides-Extra: dev
|
||||
Requires-Dist: coverage; extra == 'dev'
|
||||
Requires-Dist: pytest; extra == 'dev'
|
||||
Requires-Dist: sphinx; extra == 'dev'
|
||||
Requires-Dist: tox; extra == 'dev'
|
||||
Provides-Extra: termcolor
|
||||
Requires-Dist: termcolor; extra == 'termcolor'
|
||||
Provides-Extra: watchdog
|
||||
Requires-Dist: watchdog; extra == 'watchdog'
|
||||
|
||||
Werkzeug
|
||||
========
|
||||
|
||||
Werkzeug is a comprehensive `WSGI`_ web application library. It began as
|
||||
a simple collection of various utilities for WSGI applications and has
|
||||
become one of the most advanced WSGI utility libraries.
|
||||
|
||||
It includes:
|
||||
|
||||
* An interactive debugger that allows inspecting stack traces and source
|
||||
code in the browser with an interactive interpreter for any frame in
|
||||
the stack.
|
||||
* A full-featured request object with objects to interact with headers,
|
||||
query args, form data, files, and cookies.
|
||||
* A response object that can wrap other WSGI applications and handle
|
||||
streaming data.
|
||||
* A routing system for matching URLs to endpoints and generating URLs
|
||||
for endpoints, with an extensible system for capturing variables from
|
||||
URLs.
|
||||
* HTTP utilities to handle entity tags, cache control, dates, user
|
||||
agents, cookies, files, and more.
|
||||
* A threaded WSGI server for use while developing applications locally.
|
||||
* A test client for simulating HTTP requests during testing without
|
||||
requiring running a server.
|
||||
|
||||
Werkzeug is Unicode aware and doesn't enforce any dependencies. It is up
|
||||
to the developer to choose a template engine, database adapter, and even
|
||||
how to handle requests. It can be used to build all sorts of end user
|
||||
applications such as blogs, wikis, or bulletin boards.
|
||||
|
||||
`Flask`_ wraps Werkzeug, using it to handle the details of WSGI while
|
||||
providing more structure and patterns for defining powerful
|
||||
applications.
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
Install and update using `pip`_:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
pip install -U Werkzeug
|
||||
|
||||
|
||||
A Simple Example
|
||||
----------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from werkzeug.wrappers import Request, Response
|
||||
|
||||
@Request.application
|
||||
def application(request):
|
||||
return Response('Hello, World!')
|
||||
|
||||
if __name__ == '__main__':
|
||||
from werkzeug.serving import run_simple
|
||||
run_simple('localhost', 4000, application)
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* Website: https://www.palletsprojects.com/p/werkzeug/
|
||||
* Releases: https://pypi.org/project/Werkzeug/
|
||||
* Code: https://github.com/pallets/werkzeug
|
||||
* Issue tracker: https://github.com/pallets/werkzeug/issues
|
||||
* Test status:
|
||||
|
||||
* Linux, Mac: https://travis-ci.org/pallets/werkzeug
|
||||
* Windows: https://ci.appveyor.com/project/davidism/werkzeug
|
||||
|
||||
* Test coverage: https://codecov.io/gh/pallets/werkzeug
|
||||
|
||||
.. _WSGI: https://wsgi.readthedocs.io/en/latest/
|
||||
.. _Flask: https://www.palletsprojects.com/p/flask/
|
||||
.. _pip: https://pip.pypa.io/en/stable/quickstart/
|
||||
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
Werkzeug-0.14.1.dist-info/DESCRIPTION.rst,sha256=rOCN36jwsWtWsTpqPG96z7FMilB5qI1CIARSKRuUmz8,2452
|
||||
Werkzeug-0.14.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
Werkzeug-0.14.1.dist-info/LICENSE.txt,sha256=xndz_dD4m269AF9l_Xbl5V3tM1N3C1LoZC2PEPxWO-8,1534
|
||||
Werkzeug-0.14.1.dist-info/METADATA,sha256=FbfadrPdJNUWAxMOKxGUtHe5R3IDSBKYYmAz3FvI3uY,3872
|
||||
Werkzeug-0.14.1.dist-info/RECORD,,
|
||||
Werkzeug-0.14.1.dist-info/WHEEL,sha256=GrqQvamwgBV4nLoJe0vhYRSWzWsx7xjlt74FT0SWYfE,110
|
||||
Werkzeug-0.14.1.dist-info/metadata.json,sha256=4489UTt6HBp2NQil95-pBkjU4Je93SMHvMxZ_rjOpqA,1452
|
||||
Werkzeug-0.14.1.dist-info/top_level.txt,sha256=QRyj2VjwJoQkrwjwFIOlB8Xg3r9un0NtqVHQF-15xaw,9
|
||||
werkzeug/__init__.py,sha256=NR0d4n_-U9BLVKlOISean3zUt2vBwhvK-AZE6M0sC0k,6842
|
||||
werkzeug/__pycache__/__init__.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/_compat.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/_internal.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/_reloader.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/datastructures.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/exceptions.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/filesystem.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/formparser.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/http.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/local.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/posixemulation.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/routing.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/script.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/security.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/serving.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/test.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/testapp.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/urls.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/useragents.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/utils.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/websocket.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/wrappers.cpython-36.pyc,,
|
||||
werkzeug/__pycache__/wsgi.cpython-36.pyc,,
|
||||
werkzeug/_compat.py,sha256=8c4U9o6A_TR9nKCcTbpZNxpqCXcXDVIbFawwKM2s92c,6311
|
||||
werkzeug/_internal.py,sha256=GhEyGMlsSz_tYjsDWO9TG35VN7304MM8gjKDrXLEdVc,13873
|
||||
werkzeug/_reloader.py,sha256=AyPphcOHPbu6qzW0UbrVvTDJdre5WgpxbhIJN_TqzUc,9264
|
||||
werkzeug/contrib/__init__.py,sha256=f7PfttZhbrImqpr5Ezre8CXgwvcGUJK7zWNpO34WWrw,623
|
||||
werkzeug/contrib/__pycache__/__init__.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/atom.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/cache.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/fixers.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/iterio.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/jsrouting.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/limiter.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/lint.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/profiler.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/securecookie.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/sessions.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/testtools.cpython-36.pyc,,
|
||||
werkzeug/contrib/__pycache__/wrappers.cpython-36.pyc,,
|
||||
werkzeug/contrib/atom.py,sha256=qqfJcfIn2RYY-3hO3Oz0aLq9YuNubcPQ_KZcNsDwVJo,15575
|
||||
werkzeug/contrib/cache.py,sha256=xBImHNj09BmX_7kC5NUCx8f_l4L8_O7zi0jCL21UZKE,32163
|
||||
werkzeug/contrib/fixers.py,sha256=gR06T-w71ur-tHQ_31kP_4jpOncPJ4Wc1dOqTvYusr8,10179
|
||||
werkzeug/contrib/iterio.py,sha256=RlqDvGhz0RneTpzE8dVc-yWCUv4nkPl1jEc_EDp2fH0,10814
|
||||
werkzeug/contrib/jsrouting.py,sha256=QTmgeDoKXvNK02KzXgx9lr3cAH6fAzpwF5bBdPNvJPs,8564
|
||||
werkzeug/contrib/limiter.py,sha256=iS8-ahPZ-JLRnmfIBzxpm7O_s3lPsiDMVWv7llAIDCI,1334
|
||||
werkzeug/contrib/lint.py,sha256=Mj9NeUN7s4zIUWeQOAVjrmtZIcl3Mm2yDe9BSIr9YGE,12558
|
||||
werkzeug/contrib/profiler.py,sha256=ISwCWvwVyGpDLRBRpLjo_qUWma6GXYBrTAco4PEQSHY,5151
|
||||
werkzeug/contrib/securecookie.py,sha256=uWMyHDHY3lkeBRiCSayGqWkAIy4a7xAbSE_Hln9ecqc,12196
|
||||
werkzeug/contrib/sessions.py,sha256=39LVNvLbm5JWpbxM79WC2l87MJFbqeISARjwYbkJatw,12577
|
||||
werkzeug/contrib/testtools.py,sha256=G9xN-qeihJlhExrIZMCahvQOIDxdL9NiX874jiiHFMs,2453
|
||||
werkzeug/contrib/wrappers.py,sha256=v7OYlz7wQtDlS9fey75UiRZ1IkUWqCpzbhsLy4k14Hw,10398
|
||||
werkzeug/datastructures.py,sha256=3IgNKNqrz-ZjmAG7y3YgEYK-enDiMT_b652PsypWcYg,90080
|
||||
werkzeug/debug/__init__.py,sha256=uSn9BqCZ5E3ySgpoZtundpROGsn-uYvZtSFiTfAX24M,17452
|
||||
werkzeug/debug/__pycache__/__init__.cpython-36.pyc,,
|
||||
werkzeug/debug/__pycache__/console.cpython-36.pyc,,
|
||||
werkzeug/debug/__pycache__/repr.cpython-36.pyc,,
|
||||
werkzeug/debug/__pycache__/tbtools.cpython-36.pyc,,
|
||||
werkzeug/debug/console.py,sha256=n3-dsKk1TsjnN-u4ZgmuWCU_HO0qw5IA7ttjhyyMM6I,5607
|
||||
werkzeug/debug/repr.py,sha256=bKqstDYGfECpeLerd48s_hxuqK4b6UWnjMu3d_DHO8I,9340
|
||||
werkzeug/debug/shared/FONT_LICENSE,sha256=LwAVEI1oYnvXiNMT9SnCH_TaLCxCpeHziDrMg0gPkAI,4673
|
||||
werkzeug/debug/shared/console.png,sha256=bxax6RXXlvOij_KeqvSNX0ojJf83YbnZ7my-3Gx9w2A,507
|
||||
werkzeug/debug/shared/debugger.js,sha256=PKPVYuyO4SX1hkqLOwCLvmIEO5154WatFYaXE-zIfKI,6264
|
||||
werkzeug/debug/shared/jquery.js,sha256=7LkWEzqTdpEfELxcZZlS6wAx5Ff13zZ83lYO2_ujj7g,95957
|
||||
werkzeug/debug/shared/less.png,sha256=-4-kNRaXJSONVLahrQKUxMwXGm9R4OnZ9SxDGpHlIR4,191
|
||||
werkzeug/debug/shared/more.png,sha256=GngN7CioHQoV58rH6ojnkYi8c_qED2Aka5FO5UXrReY,200
|
||||
werkzeug/debug/shared/source.png,sha256=RoGcBTE4CyCB85GBuDGTFlAnUqxwTBiIfDqW15EpnUQ,818
|
||||
werkzeug/debug/shared/style.css,sha256=IEO0PC2pWmh2aEyGCaN--txuWsRCliuhlbEhPDFwh0A,6270
|
||||
werkzeug/debug/shared/ubuntu.ttf,sha256=1eaHFyepmy4FyDvjLVzpITrGEBu_CZYY94jE0nED1c0,70220
|
||||
werkzeug/debug/tbtools.py,sha256=rBudXCmkVdAKIcdhxANxgf09g6kQjJWW9_5bjSpr4OY,18451
|
||||
werkzeug/exceptions.py,sha256=3wp95Hqj9FqV8MdikV99JRcHse_fSMn27V8tgP5Hw2c,20505
|
||||
werkzeug/filesystem.py,sha256=hHWeWo_gqLMzTRfYt8-7n2wWcWUNTnDyudQDLOBEICE,2175
|
||||
werkzeug/formparser.py,sha256=mUuCwjzjb8_E4RzrAT2AioLuZSYpqR1KXTK6LScRYzA,21722
|
||||
werkzeug/http.py,sha256=RQg4MJuhRv2isNRiEh__Phh09ebpfT3Kuu_GfrZ54_c,40079
|
||||
werkzeug/local.py,sha256=QdQhWV5L8p1Y1CJ1CDStwxaUs24SuN5aebHwjVD08C8,14553
|
||||
werkzeug/posixemulation.py,sha256=xEF2Bxc-vUCPkiu4IbfWVd3LW7DROYAT-ExW6THqyzw,3519
|
||||
werkzeug/routing.py,sha256=2JVtdSgxKGeANy4Z_FP-dKESvKtkYGCZ1J2fARCLGCY,67214
|
||||
werkzeug/script.py,sha256=DwaVDcXdaOTffdNvlBdLitxWXjKaRVT32VbhDtljFPY,11365
|
||||
werkzeug/security.py,sha256=0m107exslz4QJLWQCpfQJ04z3re4eGHVggRvrQVAdWc,9193
|
||||
werkzeug/serving.py,sha256=A0flnIJHufdn2QJ9oeuHfrXwP3LzP8fn3rNW6hbxKUg,31926
|
||||
werkzeug/test.py,sha256=XmECSmnpASiYQTct4oMiWr0LT5jHWCtKqnpYKZd2ui8,36100
|
||||
werkzeug/testapp.py,sha256=3HQRW1sHZKXuAjCvFMet4KXtQG3loYTFnvn6LWt-4zI,9396
|
||||
werkzeug/urls.py,sha256=dUeLg2IeTm0WLmSvFeD4hBZWGdOs-uHudR5-t8n9zPo,36771
|
||||
werkzeug/useragents.py,sha256=BhYMf4cBTHyN4U0WsQedePIocmNlH_34C-UwqSThGCc,5865
|
||||
werkzeug/utils.py,sha256=BrY1j0DHQ8RTb0K1StIobKuMJhN9SQQkWEARbrh2qpk,22972
|
||||
werkzeug/websocket.py,sha256=PpSeDxXD_0UsPAa5hQhQNM6mxibeUgn8lA8eRqiS0vM,11344
|
||||
werkzeug/wrappers.py,sha256=kbyL_aFjxELwPgMwfNCYjKu-CR6kNkh-oO8wv3GXbk8,84511
|
||||
werkzeug/wsgi.py,sha256=1Nob-aeChWQf7MsiicO8RZt6J90iRzEcik44ev9Qu8s,49347
|
||||
@@ -1,6 +0,0 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.26.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"generator": "bdist_wheel (0.26.0)", "summary": "The comprehensive WSGI web application library.", "classifiers": ["Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules"], "description_content_type": "UNKNOWN", "extensions": {"python.details": {"project_urls": {"Home": "https://www.palletsprojects.org/p/werkzeug/"}, "contacts": [{"email": "armin.ronacher@active-4.com", "name": "Armin Ronacher", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst", "license": "LICENSE.txt"}}}, "license": "BSD", "metadata_version": "2.0", "name": "Werkzeug", "platform": "any", "extras": ["dev", "termcolor", "watchdog"], "run_requires": [{"requires": ["coverage", "pytest", "sphinx", "tox"], "extra": "dev"}, {"requires": ["termcolor"], "extra": "termcolor"}, {"requires": ["watchdog"], "extra": "watchdog"}], "version": "0.14.1"}
|
||||
@@ -1 +0,0 @@
|
||||
werkzeug
|
||||
Binary file not shown.
@@ -1,272 +0,0 @@
|
||||
Argh: The Natural CLI
|
||||
=====================
|
||||
|
||||
.. image:: https://img.shields.io/coveralls/neithere/argh.svg
|
||||
:target: https://coveralls.io/r/neithere/argh
|
||||
|
||||
.. image:: https://img.shields.io/travis/neithere/argh.svg
|
||||
:target: https://travis-ci.org/neithere/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/format/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/status/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/pyversions/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/dd/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://readthedocs.org/projects/argh/badge/?version=stable
|
||||
:target: http://argh.readthedocs.org/en/stable/
|
||||
|
||||
.. image:: https://readthedocs.org/projects/argh/badge/?version=latest
|
||||
:target: http://argh.readthedocs.org/en/latest/
|
||||
|
||||
Building a command-line interface? Found yourself uttering "argh!" while
|
||||
struggling with the API of `argparse`? Don't like the complexity but need
|
||||
the power?
|
||||
|
||||
.. epigraph::
|
||||
|
||||
Everything should be made as simple as possible, but no simpler.
|
||||
|
||||
-- Albert Einstein (probably)
|
||||
|
||||
`Argh` is a smart wrapper for `argparse`. `Argparse` is a very powerful tool;
|
||||
`Argh` just makes it easy to use.
|
||||
|
||||
In a nutshell
|
||||
-------------
|
||||
|
||||
`Argh`-powered applications are *simple* but *flexible*:
|
||||
|
||||
:Modular:
|
||||
Declaration of commands can be decoupled from assembling and dispatching;
|
||||
|
||||
:Pythonic:
|
||||
Commands are declared naturally, no complex API calls in most cases;
|
||||
|
||||
:Reusable:
|
||||
Commands are plain functions, can be used directly outside of CLI context;
|
||||
|
||||
:Layered:
|
||||
The complexity of code raises with requirements;
|
||||
|
||||
:Transparent:
|
||||
The full power of argparse is available whenever needed;
|
||||
|
||||
:Namespaced:
|
||||
Nested commands are a piece of cake, no messing with subparsers (though
|
||||
they are of course used under the hood);
|
||||
|
||||
:Term-Friendly:
|
||||
Command output is processed with respect to stream encoding;
|
||||
|
||||
:Unobtrusive:
|
||||
`Argh` can dispatch a subset of pure-`argparse` code, and pure-`argparse`
|
||||
code can update and dispatch a parser assembled with `Argh`;
|
||||
|
||||
:DRY:
|
||||
The amount of boilerplate code is minimal; among other things, `Argh` will:
|
||||
|
||||
* infer command name from function name;
|
||||
* infer arguments from function signature;
|
||||
* infer argument type from the default value;
|
||||
* infer argument action from the default value (for booleans);
|
||||
* add an alias root command ``help`` for the ``--help`` argument.
|
||||
|
||||
:NIH free:
|
||||
`Argh` supports *completion*, *progress bars* and everything else by being
|
||||
friendly to excellent 3rd-party libraries. No need to reinvent the wheel.
|
||||
|
||||
Sounds good? Check the tutorial!
|
||||
|
||||
Relation to argparse
|
||||
--------------------
|
||||
|
||||
`Argh` is fully compatible with `argparse`. You can mix `Argh`-agnostic and
|
||||
`Argh`-aware code. Just keep in mind that the dispatcher does some extra work
|
||||
that a custom dispatcher may not do.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Using pip::
|
||||
|
||||
$ pip install argh
|
||||
|
||||
Arch Linux (AUR)::
|
||||
|
||||
$ yaourt python-argh
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
A very simple application with one command:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import argh
|
||||
|
||||
def main():
|
||||
return 'Hello world'
|
||||
|
||||
argh.dispatch_command(main)
|
||||
|
||||
Run it:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ ./app.py
|
||||
Hello world
|
||||
|
||||
A potentially modular application with multiple commands:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import argh
|
||||
|
||||
# declaring:
|
||||
|
||||
def echo(text):
|
||||
"Returns given word as is."
|
||||
return text
|
||||
|
||||
def greet(name, greeting='Hello'):
|
||||
"Greets the user with given name. The greeting is customizable."
|
||||
return greeting + ', ' + name
|
||||
|
||||
# assembling:
|
||||
|
||||
parser = argh.ArghParser()
|
||||
parser.add_commands([echo, greet])
|
||||
|
||||
# dispatching:
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser.dispatch()
|
||||
|
||||
Of course it works:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ ./app.py greet Andy
|
||||
Hello, Andy
|
||||
|
||||
$ ./app.py greet Andy -g Arrrgh
|
||||
Arrrgh, Andy
|
||||
|
||||
Here's the auto-generated help for this application (note how the docstrings
|
||||
are reused)::
|
||||
|
||||
$ ./app.py help
|
||||
|
||||
usage: app.py {echo,greet} ...
|
||||
|
||||
positional arguments:
|
||||
echo Returns given word as is.
|
||||
greet Greets the user with given name. The greeting is customizable.
|
||||
|
||||
...and for a specific command (an ordinary function signature is converted
|
||||
to CLI arguments)::
|
||||
|
||||
$ ./app.py help greet
|
||||
|
||||
usage: app.py greet [-g GREETING] name
|
||||
|
||||
Greets the user with given name. The greeting is customizable.
|
||||
|
||||
positional arguments:
|
||||
name
|
||||
|
||||
optional arguments:
|
||||
-g GREETING, --greeting GREETING 'Hello'
|
||||
|
||||
(The help messages have been simplified a bit for brevity.)
|
||||
|
||||
`Argh` easily maps plain Python functions to CLI. Sometimes this is not
|
||||
enough; in these cases the powerful API of `argparse` is also available:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@arg('text', default='hello world', nargs='+', help='The message')
|
||||
def echo(text):
|
||||
print text
|
||||
|
||||
The approaches can be safely combined even up to this level:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# adding help to `foo` which is in the function signature:
|
||||
@arg('foo', help='blah')
|
||||
# these are not in the signature so they go to **kwargs:
|
||||
@arg('baz')
|
||||
@arg('-q', '--quux')
|
||||
# the function itself:
|
||||
def cmd(foo, bar=1, *args, **kwargs):
|
||||
yield foo
|
||||
yield bar
|
||||
yield ', '.join(args)
|
||||
yield kwargs['baz']
|
||||
yield kwargs['quux']
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* `Project home page`_ (GitHub)
|
||||
* `Documentation`_ (Read the Docs)
|
||||
* `Package distribution`_ (PyPI)
|
||||
* Questions, requests, bug reports, etc.:
|
||||
|
||||
* `Issue tracker`_ (GitHub)
|
||||
* `Mailing list`_ (subscribe to get important announcements)
|
||||
* Direct e-mail (neithere at gmail com)
|
||||
|
||||
.. _project home page: http://github.com/neithere/argh/
|
||||
.. _documentation: http://argh.readthedocs.org
|
||||
.. _package distribution: http://pypi.python.org/pypi/argh
|
||||
.. _issue tracker: http://github.com/neithere/argh/issues/
|
||||
.. _mailing list: http://groups.google.com/group/argh-users
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
Developed by Andrey Mikhaylenko since 2010.
|
||||
|
||||
See file `AUTHORS` for a complete list of contributors to this library.
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
The fastest way to improve this project is to submit tested and documented
|
||||
patches or detailed bug reports.
|
||||
|
||||
Otherwise you can "flattr" me: |FlattrLink|_
|
||||
|
||||
.. _FlattrLink: https://flattr.com/submit/auto?user_id=neithere&url=http%3A%2F%2Fpypi.python.org%2Fpypi%2Fargh
|
||||
.. |FlattrLink| image:: https://api.flattr.com/button/flattr-badge-large.png
|
||||
:alt: Flattr the Argh project
|
||||
|
||||
Licensing
|
||||
---------
|
||||
|
||||
Argh is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Argh is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Argh. If not, see <http://gnu.org/licenses/>.
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
pip
|
||||
@@ -1,300 +0,0 @@
|
||||
Metadata-Version: 2.0
|
||||
Name: argh
|
||||
Version: 0.26.2
|
||||
Summary: An unobtrusive argparse wrapper with natural syntax
|
||||
Home-page: http://github.com/neithere/argh/
|
||||
Author: Andrey Mikhaylenko
|
||||
Author-email: neithere@gmail.com
|
||||
License: GNU Lesser General Public License (LGPL), Version 3
|
||||
Keywords: cli command line argparse optparse argument option
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 4 - Beta
|
||||
Classifier: Environment :: Console
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: Intended Audience :: Information Technology
|
||||
Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.2
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: Implementation :: CPython
|
||||
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
||||
Classifier: Topic :: Software Development :: User Interfaces
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Provides: argh
|
||||
|
||||
Argh: The Natural CLI
|
||||
=====================
|
||||
|
||||
.. image:: https://img.shields.io/coveralls/neithere/argh.svg
|
||||
:target: https://coveralls.io/r/neithere/argh
|
||||
|
||||
.. image:: https://img.shields.io/travis/neithere/argh.svg
|
||||
:target: https://travis-ci.org/neithere/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/format/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/status/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/pyversions/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://img.shields.io/pypi/dd/argh.svg
|
||||
:target: https://pypi.python.org/pypi/argh
|
||||
|
||||
.. image:: https://readthedocs.org/projects/argh/badge/?version=stable
|
||||
:target: http://argh.readthedocs.org/en/stable/
|
||||
|
||||
.. image:: https://readthedocs.org/projects/argh/badge/?version=latest
|
||||
:target: http://argh.readthedocs.org/en/latest/
|
||||
|
||||
Building a command-line interface? Found yourself uttering "argh!" while
|
||||
struggling with the API of `argparse`? Don't like the complexity but need
|
||||
the power?
|
||||
|
||||
.. epigraph::
|
||||
|
||||
Everything should be made as simple as possible, but no simpler.
|
||||
|
||||
-- Albert Einstein (probably)
|
||||
|
||||
`Argh` is a smart wrapper for `argparse`. `Argparse` is a very powerful tool;
|
||||
`Argh` just makes it easy to use.
|
||||
|
||||
In a nutshell
|
||||
-------------
|
||||
|
||||
`Argh`-powered applications are *simple* but *flexible*:
|
||||
|
||||
:Modular:
|
||||
Declaration of commands can be decoupled from assembling and dispatching;
|
||||
|
||||
:Pythonic:
|
||||
Commands are declared naturally, no complex API calls in most cases;
|
||||
|
||||
:Reusable:
|
||||
Commands are plain functions, can be used directly outside of CLI context;
|
||||
|
||||
:Layered:
|
||||
The complexity of code raises with requirements;
|
||||
|
||||
:Transparent:
|
||||
The full power of argparse is available whenever needed;
|
||||
|
||||
:Namespaced:
|
||||
Nested commands are a piece of cake, no messing with subparsers (though
|
||||
they are of course used under the hood);
|
||||
|
||||
:Term-Friendly:
|
||||
Command output is processed with respect to stream encoding;
|
||||
|
||||
:Unobtrusive:
|
||||
`Argh` can dispatch a subset of pure-`argparse` code, and pure-`argparse`
|
||||
code can update and dispatch a parser assembled with `Argh`;
|
||||
|
||||
:DRY:
|
||||
The amount of boilerplate code is minimal; among other things, `Argh` will:
|
||||
|
||||
* infer command name from function name;
|
||||
* infer arguments from function signature;
|
||||
* infer argument type from the default value;
|
||||
* infer argument action from the default value (for booleans);
|
||||
* add an alias root command ``help`` for the ``--help`` argument.
|
||||
|
||||
:NIH free:
|
||||
`Argh` supports *completion*, *progress bars* and everything else by being
|
||||
friendly to excellent 3rd-party libraries. No need to reinvent the wheel.
|
||||
|
||||
Sounds good? Check the tutorial!
|
||||
|
||||
Relation to argparse
|
||||
--------------------
|
||||
|
||||
`Argh` is fully compatible with `argparse`. You can mix `Argh`-agnostic and
|
||||
`Argh`-aware code. Just keep in mind that the dispatcher does some extra work
|
||||
that a custom dispatcher may not do.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Using pip::
|
||||
|
||||
$ pip install argh
|
||||
|
||||
Arch Linux (AUR)::
|
||||
|
||||
$ yaourt python-argh
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
A very simple application with one command:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import argh
|
||||
|
||||
def main():
|
||||
return 'Hello world'
|
||||
|
||||
argh.dispatch_command(main)
|
||||
|
||||
Run it:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ ./app.py
|
||||
Hello world
|
||||
|
||||
A potentially modular application with multiple commands:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import argh
|
||||
|
||||
# declaring:
|
||||
|
||||
def echo(text):
|
||||
"Returns given word as is."
|
||||
return text
|
||||
|
||||
def greet(name, greeting='Hello'):
|
||||
"Greets the user with given name. The greeting is customizable."
|
||||
return greeting + ', ' + name
|
||||
|
||||
# assembling:
|
||||
|
||||
parser = argh.ArghParser()
|
||||
parser.add_commands([echo, greet])
|
||||
|
||||
# dispatching:
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser.dispatch()
|
||||
|
||||
Of course it works:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ ./app.py greet Andy
|
||||
Hello, Andy
|
||||
|
||||
$ ./app.py greet Andy -g Arrrgh
|
||||
Arrrgh, Andy
|
||||
|
||||
Here's the auto-generated help for this application (note how the docstrings
|
||||
are reused)::
|
||||
|
||||
$ ./app.py help
|
||||
|
||||
usage: app.py {echo,greet} ...
|
||||
|
||||
positional arguments:
|
||||
echo Returns given word as is.
|
||||
greet Greets the user with given name. The greeting is customizable.
|
||||
|
||||
...and for a specific command (an ordinary function signature is converted
|
||||
to CLI arguments)::
|
||||
|
||||
$ ./app.py help greet
|
||||
|
||||
usage: app.py greet [-g GREETING] name
|
||||
|
||||
Greets the user with given name. The greeting is customizable.
|
||||
|
||||
positional arguments:
|
||||
name
|
||||
|
||||
optional arguments:
|
||||
-g GREETING, --greeting GREETING 'Hello'
|
||||
|
||||
(The help messages have been simplified a bit for brevity.)
|
||||
|
||||
`Argh` easily maps plain Python functions to CLI. Sometimes this is not
|
||||
enough; in these cases the powerful API of `argparse` is also available:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@arg('text', default='hello world', nargs='+', help='The message')
|
||||
def echo(text):
|
||||
print text
|
||||
|
||||
The approaches can be safely combined even up to this level:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# adding help to `foo` which is in the function signature:
|
||||
@arg('foo', help='blah')
|
||||
# these are not in the signature so they go to **kwargs:
|
||||
@arg('baz')
|
||||
@arg('-q', '--quux')
|
||||
# the function itself:
|
||||
def cmd(foo, bar=1, *args, **kwargs):
|
||||
yield foo
|
||||
yield bar
|
||||
yield ', '.join(args)
|
||||
yield kwargs['baz']
|
||||
yield kwargs['quux']
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* `Project home page`_ (GitHub)
|
||||
* `Documentation`_ (Read the Docs)
|
||||
* `Package distribution`_ (PyPI)
|
||||
* Questions, requests, bug reports, etc.:
|
||||
|
||||
* `Issue tracker`_ (GitHub)
|
||||
* `Mailing list`_ (subscribe to get important announcements)
|
||||
* Direct e-mail (neithere at gmail com)
|
||||
|
||||
.. _project home page: http://github.com/neithere/argh/
|
||||
.. _documentation: http://argh.readthedocs.org
|
||||
.. _package distribution: http://pypi.python.org/pypi/argh
|
||||
.. _issue tracker: http://github.com/neithere/argh/issues/
|
||||
.. _mailing list: http://groups.google.com/group/argh-users
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
Developed by Andrey Mikhaylenko since 2010.
|
||||
|
||||
See file `AUTHORS` for a complete list of contributors to this library.
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
The fastest way to improve this project is to submit tested and documented
|
||||
patches or detailed bug reports.
|
||||
|
||||
Otherwise you can "flattr" me: |FlattrLink|_
|
||||
|
||||
.. _FlattrLink: https://flattr.com/submit/auto?user_id=neithere&url=http%3A%2F%2Fpypi.python.org%2Fpypi%2Fargh
|
||||
.. |FlattrLink| image:: https://api.flattr.com/button/flattr-badge-large.png
|
||||
:alt: Flattr the Argh project
|
||||
|
||||
Licensing
|
||||
---------
|
||||
|
||||
Argh is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Argh is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Argh. If not, see <http://gnu.org/licenses/>.
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
argh-0.26.2.dist-info/DESCRIPTION.rst,sha256=lkRPNeZEMGOKCCfCGZ4_-2iPxLvQ3xyccMH7SUfEJ5Q,7304
|
||||
argh-0.26.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
argh-0.26.2.dist-info/METADATA,sha256=opzH3aI3sMQFcRmdmcrFR14tZfX6eJYsY6fi9HhivYI,8557
|
||||
argh-0.26.2.dist-info/RECORD,,
|
||||
argh-0.26.2.dist-info/WHEEL,sha256=o2k-Qa-RMNIJmUdIc7KU6VWR_ErNRbWNlxDIpl7lm34,110
|
||||
argh-0.26.2.dist-info/metadata.json,sha256=pbgTgagWaqB_H3oMqcB3xmA4mln1QBf-aAh-iGLHIUA,1408
|
||||
argh-0.26.2.dist-info/top_level.txt,sha256=KbRbUYCNA1IhMbo789mEq1eXr9-lhdgo1K6Ww_p7zM0,5
|
||||
argh/__init__.py,sha256=GemyWFY_3uaAOGEzxWtvU6trRx_s9Z5OaC7tS1Xaxn0,495
|
||||
argh/__pycache__/__init__.cpython-36.pyc,,
|
||||
argh/__pycache__/assembling.cpython-36.pyc,,
|
||||
argh/__pycache__/compat.cpython-36.pyc,,
|
||||
argh/__pycache__/completion.cpython-36.pyc,,
|
||||
argh/__pycache__/constants.cpython-36.pyc,,
|
||||
argh/__pycache__/decorators.cpython-36.pyc,,
|
||||
argh/__pycache__/dispatching.cpython-36.pyc,,
|
||||
argh/__pycache__/exceptions.cpython-36.pyc,,
|
||||
argh/__pycache__/helpers.cpython-36.pyc,,
|
||||
argh/__pycache__/interaction.cpython-36.pyc,,
|
||||
argh/__pycache__/io.cpython-36.pyc,,
|
||||
argh/__pycache__/utils.cpython-36.pyc,,
|
||||
argh/assembling.py,sha256=rHn8Qh5hKk4NhEgqA0NECja4ZnxkHM4ywMqKE5eJEVw,17555
|
||||
argh/compat.py,sha256=DThKad-IYxH-vz3DQDdObHOOwCOWvJH4H2rM4Iq_yZs,2834
|
||||
argh/completion.py,sha256=oxj9vfyI1WATZRnlwcc7m__-uwM3-Eqdi-WzR3wnMus,2943
|
||||
argh/constants.py,sha256=FpUSsGACMlGgZZuaqa79BwVROojE5ABJ2OQgkXS2e6A,3436
|
||||
argh/decorators.py,sha256=qAdU2Y2vQdIshrABdJoliNMSSOjetZN4EpkpZ3sQ0AM,6141
|
||||
argh/dispatching.py,sha256=5Bg22bf3MJZrvv3B4CtcLu_Nuq_RLLyBxkl4Vlvl4nw,12465
|
||||
argh/exceptions.py,sha256=x_UJbpOkdm-qfOdp1A4ERvPB0JkqL74GXTlXwqu6E-I,1545
|
||||
argh/helpers.py,sha256=SKAB5AQrmsXczTmL9QkzBJVlWE7zAGqwxhYvpU1menQ,2151
|
||||
argh/interaction.py,sha256=XKlTPo0lru_VYd2Jppm-LlZoW8oDVvSgqOyjPjsdzVM,2403
|
||||
argh/io.py,sha256=nfnyC53E_KYXJsCg3fEiNqHBqs-e2TC-x1KrkWVI3Vw,2986
|
||||
argh/utils.py,sha256=4yI6-_Q33m4vrthwVpFI3ZlIWGZ_bx7Tff7BGuEB1E4,1676
|
||||
@@ -1,6 +0,0 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.29.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"classifiers": ["Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: User Interfaces", "Topic :: Software Development :: Libraries :: Python Modules"], "extensions": {"python.details": {"contacts": [{"email": "neithere@gmail.com", "name": "Andrey Mikhaylenko", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "http://github.com/neithere/argh/"}}}, "generator": "bdist_wheel (0.29.0)", "keywords": ["cli", "command", "line", "argparse", "optparse", "argument", "option"], "license": "GNU Lesser General Public License (LGPL), Version 3", "metadata_version": "2.0", "name": "argh", "provides": "argh", "summary": "An unobtrusive argparse wrapper with natural syntax", "test_requires": [{"requires": ["iocapture", "mock", "pytest"]}], "version": "0.26.2"}
|
||||
@@ -1 +0,0 @@
|
||||
argh
|
||||
@@ -1,19 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
from .assembling import *
|
||||
from .decorators import *
|
||||
from .dispatching import *
|
||||
from .exceptions import *
|
||||
from .interaction import *
|
||||
from .helpers import *
|
||||
|
||||
|
||||
__version__ = '0.26.2'
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,501 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Assembling
|
||||
~~~~~~~~~~
|
||||
|
||||
Functions and classes to properly assemble your commands in a parser.
|
||||
"""
|
||||
import argparse
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from argh.completion import COMPLETION_ENABLED
|
||||
from argh.compat import OrderedDict
|
||||
from argh.constants import (
|
||||
ATTR_ALIASES,
|
||||
ATTR_ARGS,
|
||||
ATTR_NAME,
|
||||
ATTR_EXPECTS_NAMESPACE_OBJECT,
|
||||
PARSER_FORMATTER,
|
||||
DEFAULT_ARGUMENT_TEMPLATE,
|
||||
DEST_FUNCTION,
|
||||
)
|
||||
from argh.utils import get_subparsers, get_arg_spec
|
||||
from argh.exceptions import AssemblingError
|
||||
|
||||
|
||||
__all__ = [
|
||||
'SUPPORTS_ALIASES',
|
||||
'set_default_command',
|
||||
'add_commands',
|
||||
'add_subcommands',
|
||||
]
|
||||
|
||||
|
||||
def _check_support_aliases():
|
||||
p = argparse.ArgumentParser()
|
||||
s = p.add_subparsers()
|
||||
try:
|
||||
s.add_parser('x', aliases=[])
|
||||
except TypeError:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
SUPPORTS_ALIASES = _check_support_aliases()
|
||||
"""
|
||||
Calculated on load. If `True`, current version of argparse supports
|
||||
alternative command names (can be set via :func:`~argh.decorators.aliases`).
|
||||
"""
|
||||
|
||||
|
||||
def _get_args_from_signature(function):
|
||||
if getattr(function, ATTR_EXPECTS_NAMESPACE_OBJECT, False):
|
||||
return
|
||||
|
||||
spec = get_arg_spec(function)
|
||||
|
||||
defaults = dict(zip(*[reversed(x) for x in (spec.args,
|
||||
spec.defaults or [])]))
|
||||
defaults.update(getattr(spec, 'kwonlydefaults', None) or {})
|
||||
|
||||
kwonly = getattr(spec, 'kwonlyargs', [])
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
annotations = {}
|
||||
else:
|
||||
annotations = dict((k,v) for k,v in function.__annotations__.items()
|
||||
if isinstance(v, str))
|
||||
|
||||
# define the list of conflicting option strings
|
||||
# (short forms, i.e. single-character ones)
|
||||
chars = [a[0] for a in spec.args + kwonly]
|
||||
char_counts = dict((char, chars.count(char)) for char in set(chars))
|
||||
conflicting_opts = tuple(char for char in char_counts
|
||||
if 1 < char_counts[char])
|
||||
|
||||
for name in spec.args + kwonly:
|
||||
flags = [] # name_or_flags
|
||||
akwargs = {} # keyword arguments for add_argument()
|
||||
|
||||
if name in annotations:
|
||||
# help message: func(a : "b") -> add_argument("a", help="b")
|
||||
akwargs.update(help=annotations.get(name))
|
||||
|
||||
if name in defaults or name in kwonly:
|
||||
if name in defaults:
|
||||
akwargs.update(default=defaults.get(name))
|
||||
else:
|
||||
akwargs.update(required=True)
|
||||
flags = ('-{0}'.format(name[0]), '--{0}'.format(name))
|
||||
if name.startswith(conflicting_opts):
|
||||
# remove short name
|
||||
flags = flags[1:]
|
||||
|
||||
else:
|
||||
# positional argument
|
||||
flags = (name,)
|
||||
|
||||
# cmd(foo_bar) -> add_argument('foo-bar')
|
||||
flags = tuple(x.replace('_', '-') for x in flags)
|
||||
|
||||
yield dict(option_strings=flags, **akwargs)
|
||||
|
||||
if spec.varargs:
|
||||
# *args
|
||||
yield dict(option_strings=[spec.varargs], nargs='*')
|
||||
|
||||
|
||||
def _guess(kwargs):
|
||||
"""
|
||||
Adds types, actions, etc. to given argument specification.
|
||||
For example, ``default=3`` implies ``type=int``.
|
||||
|
||||
:param arg: a :class:`argh.utils.Arg` instance
|
||||
"""
|
||||
guessed = {}
|
||||
|
||||
# Parser actions that accept argument 'type'
|
||||
TYPE_AWARE_ACTIONS = 'store', 'append'
|
||||
|
||||
# guess type/action from default value
|
||||
value = kwargs.get('default')
|
||||
if value is not None:
|
||||
if isinstance(value, bool):
|
||||
if kwargs.get('action') is None:
|
||||
# infer action from default value
|
||||
guessed['action'] = 'store_false' if value else 'store_true'
|
||||
elif kwargs.get('type') is None:
|
||||
# infer type from default value
|
||||
# (make sure that action handler supports this keyword)
|
||||
if kwargs.get('action', 'store') in TYPE_AWARE_ACTIONS:
|
||||
guessed['type'] = type(value)
|
||||
|
||||
# guess type from choices (first item)
|
||||
if kwargs.get('choices') and 'type' not in list(guessed) + list(kwargs):
|
||||
guessed['type'] = type(kwargs['choices'][0])
|
||||
|
||||
return dict(kwargs, **guessed)
|
||||
|
||||
|
||||
def _is_positional(args, prefix_chars='-'):
|
||||
assert args
|
||||
if 1 < len(args) or args[0][0].startswith(tuple(prefix_chars)):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def _get_parser_param_kwargs(parser, argspec):
|
||||
argspec = argspec.copy() # parser methods modify source data
|
||||
args = argspec['option_strings']
|
||||
|
||||
if _is_positional(args, prefix_chars=parser.prefix_chars):
|
||||
get_kwargs = parser._get_positional_kwargs
|
||||
else:
|
||||
get_kwargs = parser._get_optional_kwargs
|
||||
|
||||
kwargs = get_kwargs(*args, **argspec)
|
||||
|
||||
kwargs['dest'] = kwargs['dest'].replace('-', '_')
|
||||
|
||||
return kwargs
|
||||
|
||||
|
||||
def _get_dest(parser, argspec):
|
||||
kwargs = _get_parser_param_kwargs(parser, argspec)
|
||||
return kwargs['dest']
|
||||
|
||||
|
||||
def _require_support_for_default_command_with_subparsers():
|
||||
if sys.version_info < (3,4):
|
||||
raise AssemblingError(
|
||||
'Argparse library bundled with this version of Python '
|
||||
'does not support combining a default command with nested ones.')
|
||||
|
||||
|
||||
def set_default_command(parser, function):
|
||||
"""
|
||||
Sets default command (i.e. a function) for given parser.
|
||||
|
||||
If `parser.description` is empty and the function has a docstring,
|
||||
it is used as the description.
|
||||
|
||||
.. note::
|
||||
|
||||
An attempt to set default command to a parser which already has
|
||||
subparsers (e.g. added with :func:`~argh.assembling.add_commands`)
|
||||
results in a `AssemblingError`.
|
||||
|
||||
.. note::
|
||||
|
||||
If there are both explicitly declared arguments (e.g. via
|
||||
:func:`~argh.decorators.arg`) and ones inferred from the function
|
||||
signature (e.g. via :func:`~argh.decorators.command`), declared ones
|
||||
will be merged into inferred ones. If an argument does not conform
|
||||
function signature, `AssemblingError` is raised.
|
||||
|
||||
.. note::
|
||||
|
||||
If the parser was created with ``add_help=True`` (which is by default),
|
||||
option name ``-h`` is silently removed from any argument.
|
||||
|
||||
"""
|
||||
if parser._subparsers:
|
||||
_require_support_for_default_command_with_subparsers()
|
||||
|
||||
spec = get_arg_spec(function)
|
||||
|
||||
declared_args = getattr(function, ATTR_ARGS, [])
|
||||
inferred_args = list(_get_args_from_signature(function))
|
||||
|
||||
if inferred_args and declared_args:
|
||||
# We've got a mixture of declared and inferred arguments
|
||||
|
||||
# a mapping of "dest" strings to argument declarations.
|
||||
#
|
||||
# * a "dest" string is a normalized form of argument name, i.e.:
|
||||
#
|
||||
# '-f', '--foo' → 'foo'
|
||||
# 'foo-bar' → 'foo_bar'
|
||||
#
|
||||
# * argument declaration is a dictionary representing an argument;
|
||||
# it is obtained either from _get_args_from_signature() or from
|
||||
# an @arg decorator (as is).
|
||||
#
|
||||
dests = OrderedDict()
|
||||
|
||||
for argspec in inferred_args:
|
||||
dest = _get_parser_param_kwargs(parser, argspec)['dest']
|
||||
dests[dest] = argspec
|
||||
|
||||
for declared_kw in declared_args:
|
||||
# an argument is declared via decorator
|
||||
dest = _get_dest(parser, declared_kw)
|
||||
if dest in dests:
|
||||
# the argument is already known from function signature
|
||||
#
|
||||
# now make sure that this declared arg conforms to the function
|
||||
# signature and therefore only refines an inferred arg:
|
||||
#
|
||||
# @arg('my-foo') maps to func(my_foo)
|
||||
# @arg('--my-bar') maps to func(my_bar=...)
|
||||
|
||||
# either both arguments are positional or both are optional
|
||||
decl_positional = _is_positional(declared_kw['option_strings'])
|
||||
infr_positional = _is_positional(dests[dest]['option_strings'])
|
||||
if decl_positional != infr_positional:
|
||||
kinds = {True: 'positional', False: 'optional'}
|
||||
raise AssemblingError(
|
||||
'{func}: argument "{dest}" declared as {kind_i} '
|
||||
'(in function signature) and {kind_d} (via decorator)'
|
||||
.format(
|
||||
func=function.__name__,
|
||||
dest=dest,
|
||||
kind_i=kinds[infr_positional],
|
||||
kind_d=kinds[decl_positional],
|
||||
))
|
||||
|
||||
# merge explicit argument declaration into the inferred one
|
||||
# (e.g. `help=...`)
|
||||
dests[dest].update(**declared_kw)
|
||||
else:
|
||||
# the argument is not in function signature
|
||||
varkw = getattr(spec, 'varkw', getattr(spec, 'keywords', []))
|
||||
if varkw:
|
||||
# function accepts **kwargs; the argument goes into it
|
||||
dests[dest] = declared_kw
|
||||
else:
|
||||
# there's no way we can map the argument declaration
|
||||
# to function signature
|
||||
xs = (dests[x]['option_strings'] for x in dests)
|
||||
raise AssemblingError(
|
||||
'{func}: argument {flags} does not fit '
|
||||
'function signature: {sig}'.format(
|
||||
flags=', '.join(declared_kw['option_strings']),
|
||||
func=function.__name__,
|
||||
sig=', '.join('/'.join(x) for x in xs)))
|
||||
|
||||
# pack the modified data back into a list
|
||||
inferred_args = dests.values()
|
||||
|
||||
command_args = inferred_args or declared_args
|
||||
|
||||
# add types, actions, etc. (e.g. default=3 implies type=int)
|
||||
command_args = [_guess(x) for x in command_args]
|
||||
|
||||
for draft in command_args:
|
||||
draft = draft.copy()
|
||||
if 'help' not in draft:
|
||||
draft.update(help=DEFAULT_ARGUMENT_TEMPLATE)
|
||||
dest_or_opt_strings = draft.pop('option_strings')
|
||||
if parser.add_help and '-h' in dest_or_opt_strings:
|
||||
dest_or_opt_strings = [x for x in dest_or_opt_strings if x != '-h']
|
||||
completer = draft.pop('completer', None)
|
||||
try:
|
||||
action = parser.add_argument(*dest_or_opt_strings, **draft)
|
||||
if COMPLETION_ENABLED and completer:
|
||||
action.completer = completer
|
||||
except Exception as e:
|
||||
raise type(e)('{func}: cannot add arg {args}: {msg}'.format(
|
||||
args='/'.join(dest_or_opt_strings), func=function.__name__, msg=e))
|
||||
|
||||
if function.__doc__ and not parser.description:
|
||||
parser.description = function.__doc__
|
||||
parser.set_defaults(**{
|
||||
DEST_FUNCTION: function,
|
||||
})
|
||||
|
||||
|
||||
def add_commands(parser, functions, namespace=None, namespace_kwargs=None,
|
||||
func_kwargs=None,
|
||||
# deprecated args:
|
||||
title=None, description=None, help=None):
|
||||
"""
|
||||
Adds given functions as commands to given parser.
|
||||
|
||||
:param parser:
|
||||
|
||||
an :class:`argparse.ArgumentParser` instance.
|
||||
|
||||
:param functions:
|
||||
|
||||
a list of functions. A subparser is created for each of them.
|
||||
If the function is decorated with :func:`~argh.decorators.arg`, the
|
||||
arguments are passed to :class:`argparse.ArgumentParser.add_argument`.
|
||||
See also :func:`~argh.dispatching.dispatch` for requirements
|
||||
concerning function signatures. The command name is inferred from the
|
||||
function name. Note that the underscores in the name are replaced with
|
||||
hyphens, i.e. function name "foo_bar" becomes command name "foo-bar".
|
||||
|
||||
:param namespace:
|
||||
|
||||
an optional string representing the group of commands. For example, if
|
||||
a command named "hello" is added without the namespace, it will be
|
||||
available as "prog.py hello"; if the namespace if specified as "greet",
|
||||
then the command will be accessible as "prog.py greet hello". The
|
||||
namespace itself is not callable, so "prog.py greet" will fail and only
|
||||
display a help message.
|
||||
|
||||
:param func_kwargs:
|
||||
|
||||
a `dict` of keyword arguments to be passed to each nested ArgumentParser
|
||||
instance created per command (i.e. per function). Members of this
|
||||
dictionary have the highest priority, so a function's docstring is
|
||||
overridden by a `help` in `func_kwargs` (if present).
|
||||
|
||||
:param namespace_kwargs:
|
||||
|
||||
a `dict` of keyword arguments to be passed to the nested ArgumentParser
|
||||
instance under given `namespace`.
|
||||
|
||||
Deprecated params that should be moved into `namespace_kwargs`:
|
||||
|
||||
:param title:
|
||||
|
||||
passed to :meth:`argparse.ArgumentParser.add_subparsers` as `title`.
|
||||
|
||||
.. deprecated:: 0.26.0
|
||||
|
||||
Please use `namespace_kwargs` instead.
|
||||
|
||||
:param description:
|
||||
|
||||
passed to :meth:`argparse.ArgumentParser.add_subparsers` as
|
||||
`description`.
|
||||
|
||||
.. deprecated:: 0.26.0
|
||||
|
||||
Please use `namespace_kwargs` instead.
|
||||
|
||||
:param help:
|
||||
|
||||
passed to :meth:`argparse.ArgumentParser.add_subparsers` as `help`.
|
||||
|
||||
.. deprecated:: 0.26.0
|
||||
|
||||
Please use `namespace_kwargs` instead.
|
||||
|
||||
.. note::
|
||||
|
||||
This function modifies the parser object. Generally side effects are
|
||||
bad practice but we don't seem to have any choice as ArgumentParser is
|
||||
pretty opaque.
|
||||
You may prefer :class:`~argh.helpers.ArghParser.add_commands` for a bit
|
||||
more predictable API.
|
||||
|
||||
.. note::
|
||||
|
||||
An attempt to add commands to a parser which already has a default
|
||||
function (e.g. added with :func:`~argh.assembling.set_default_command`)
|
||||
results in `AssemblingError`.
|
||||
|
||||
"""
|
||||
# FIXME "namespace" is a correct name but it clashes with the "namespace"
|
||||
# that represents arguments (argparse.Namespace and our ArghNamespace).
|
||||
# We should rename the argument here.
|
||||
|
||||
if DEST_FUNCTION in parser._defaults:
|
||||
_require_support_for_default_command_with_subparsers()
|
||||
|
||||
namespace_kwargs = namespace_kwargs or {}
|
||||
|
||||
# FIXME remove this by 1.0
|
||||
#
|
||||
if title:
|
||||
warnings.warn('argument `title` is deprecated in add_commands(),'
|
||||
' use `parser_kwargs` instead', DeprecationWarning)
|
||||
namespace_kwargs['description'] = title
|
||||
if help:
|
||||
warnings.warn('argument `help` is deprecated in add_commands(),'
|
||||
' use `parser_kwargs` instead', DeprecationWarning)
|
||||
namespace_kwargs['help'] = help
|
||||
if description:
|
||||
warnings.warn('argument `description` is deprecated in add_commands(),'
|
||||
' use `parser_kwargs` instead', DeprecationWarning)
|
||||
namespace_kwargs['description'] = description
|
||||
#
|
||||
# /
|
||||
|
||||
subparsers_action = get_subparsers(parser, create=True)
|
||||
|
||||
if namespace:
|
||||
# Make a nested parser and init a deeper _SubParsersAction under it.
|
||||
|
||||
# Create a named group of commands. It will be listed along with
|
||||
# root-level commands in ``app.py --help``; in that context its `title`
|
||||
# can be used as a short description on the right side of its name.
|
||||
# Normally `title` is shown above the list of commands
|
||||
# in ``app.py my-namespace --help``.
|
||||
subsubparser_kw = {
|
||||
'help': namespace_kwargs.get('title'),
|
||||
}
|
||||
subsubparser = subparsers_action.add_parser(namespace, **subsubparser_kw)
|
||||
subparsers_action = subsubparser.add_subparsers(**namespace_kwargs)
|
||||
else:
|
||||
assert not namespace_kwargs, ('`parser_kwargs` only makes sense '
|
||||
'with `namespace`.')
|
||||
|
||||
for func in functions:
|
||||
cmd_name, func_parser_kwargs = _extract_command_meta_from_func(func)
|
||||
|
||||
# override any computed kwargs by manually supplied ones
|
||||
if func_kwargs:
|
||||
func_parser_kwargs.update(func_kwargs)
|
||||
|
||||
# create and set up the parser for this command
|
||||
command_parser = subparsers_action.add_parser(cmd_name, **func_parser_kwargs)
|
||||
set_default_command(command_parser, func)
|
||||
|
||||
|
||||
def _extract_command_meta_from_func(func):
|
||||
# use explicitly defined name; if none, use function name (a_b → a-b)
|
||||
cmd_name = getattr(func, ATTR_NAME,
|
||||
func.__name__.replace('_','-'))
|
||||
|
||||
func_parser_kwargs = {
|
||||
|
||||
# add command help from function's docstring
|
||||
'help': func.__doc__,
|
||||
|
||||
# set default formatter
|
||||
'formatter_class': PARSER_FORMATTER,
|
||||
|
||||
}
|
||||
|
||||
# try adding aliases for command name
|
||||
if SUPPORTS_ALIASES:
|
||||
func_parser_kwargs['aliases'] = getattr(func, ATTR_ALIASES, [])
|
||||
|
||||
return cmd_name, func_parser_kwargs
|
||||
|
||||
|
||||
def add_subcommands(parser, namespace, functions, **namespace_kwargs):
|
||||
"""
|
||||
A wrapper for :func:`add_commands`.
|
||||
|
||||
These examples are equivalent::
|
||||
|
||||
add_commands(parser, [get, put], namespace='db',
|
||||
namespace_kwargs={
|
||||
'title': 'database commands',
|
||||
'help': 'CRUD for our silly database'
|
||||
})
|
||||
|
||||
add_subcommands(parser, 'db', [get, put],
|
||||
title='database commands',
|
||||
help='CRUD for our silly database')
|
||||
|
||||
"""
|
||||
add_commands(parser, functions, namespace=namespace,
|
||||
namespace_kwargs=namespace_kwargs)
|
||||
@@ -1,92 +0,0 @@
|
||||
# originally inspired by "six" by Benjamin Peterson
|
||||
|
||||
import inspect
|
||||
import sys
|
||||
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
text_type = unicode
|
||||
binary_type = str
|
||||
|
||||
import StringIO
|
||||
StringIO = BytesIO = StringIO.StringIO
|
||||
else:
|
||||
text_type = str
|
||||
binary_type = bytes
|
||||
|
||||
import io
|
||||
StringIO = io.StringIO
|
||||
BytesIO = io.BytesIO
|
||||
|
||||
|
||||
def getargspec_permissive(func):
|
||||
"""
|
||||
An `inspect.getargspec` with a relaxed sanity check to support Cython.
|
||||
|
||||
Motivation:
|
||||
|
||||
A Cython-compiled function is *not* an instance of Python's
|
||||
types.FunctionType. That is the sanity check the standard Py2
|
||||
library uses in `inspect.getargspec()`. So, an exception is raised
|
||||
when calling `argh.dispatch_command(cythonCompiledFunc)`. However,
|
||||
the CyFunctions do have perfectly usable `.func_code` and
|
||||
`.func_defaults` which is all `inspect.getargspec` needs.
|
||||
|
||||
This function just copies `inspect.getargspec()` from the standard
|
||||
library but relaxes the test to a more duck-typing one of having
|
||||
both `.func_code` and `.func_defaults` attributes.
|
||||
"""
|
||||
if inspect.ismethod(func):
|
||||
func = func.im_func
|
||||
|
||||
# Py2 Stdlib uses isfunction(func) which is too strict for Cython-compiled
|
||||
# functions though such have perfectly usable func_code, func_defaults.
|
||||
if not (hasattr(func, "func_code") and hasattr(func, "func_defaults")):
|
||||
raise TypeError('{!r} missing func_code or func_defaults'.format(func))
|
||||
|
||||
args, varargs, varkw = inspect.getargs(func.func_code)
|
||||
return inspect.ArgSpec(args, varargs, varkw, func.func_defaults)
|
||||
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
getargspec = getargspec_permissive
|
||||
else:
|
||||
# in Python 3 the basic getargspec doesn't support keyword-only arguments
|
||||
# and annotations and raises ValueError if they are discovered
|
||||
getargspec = inspect.getfullargspec
|
||||
|
||||
|
||||
class _PrimitiveOrderedDict(dict):
|
||||
"""
|
||||
A poor man's OrderedDict replacement for compatibility with Python 2.6.
|
||||
Implements only the basic features. May easily break if non-overloaded
|
||||
methods are used.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(_PrimitiveOrderedDict, self).__init__(*args, **kwargs)
|
||||
self._seq = []
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
super(_PrimitiveOrderedDict, self).__setitem__(key, value)
|
||||
if key not in self._seq:
|
||||
self._seq.append(key)
|
||||
|
||||
def __delitem__(self, key):
|
||||
super(_PrimitiveOrderedDict, self).__delitem__(key)
|
||||
idx = self._seq.index(key)
|
||||
del self._seq[idx]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._seq)
|
||||
|
||||
def keys(self):
|
||||
return list(self)
|
||||
|
||||
def values(self):
|
||||
return [self[k] for k in self]
|
||||
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
OrderedDict = _PrimitiveOrderedDict
|
||||
@@ -1,94 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Shell completion
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Command and argument completion is a great way to reduce the number of
|
||||
keystrokes and improve user experience.
|
||||
|
||||
To display suggestions when you press :kbd:`tab`, a shell must obtain choices
|
||||
from your program. It calls the program in a specific environment and expects
|
||||
it to return a list of relevant choices.
|
||||
|
||||
`Argparse` does not support completion out of the box. However, there are
|
||||
3rd-party apps that do the job, such as argcomplete_ and
|
||||
python-selfcompletion_.
|
||||
|
||||
`Argh` supports only argcomplete_ which doesn't require subclassing
|
||||
the parser and monkey-patches it instead. Combining `Argh`
|
||||
with python-selfcompletion_ isn't much harder though: simply use
|
||||
`SelfCompletingArgumentParser` instead of vanilla `ArgumentParser`.
|
||||
|
||||
See installation details and gotchas in the documentation of the 3rd-party app
|
||||
you've chosen for the completion backend.
|
||||
|
||||
`Argh` automatically enables completion if argcomplete_ is available
|
||||
(see :attr:`COMPLETION_ENABLED`). If completion is undesirable in given app by
|
||||
design, it can be turned off by setting ``completion=False``
|
||||
in :func:`argh.dispatching.dispatch`.
|
||||
|
||||
Note that you don't *have* to add completion via `Argh`; it doesn't matter
|
||||
whether you let it do it for you or use the underlying API.
|
||||
|
||||
.. _argcomplete: https://github.com/kislyuk/argcomplete
|
||||
.. _python-selfcompletion: https://github.com/dbarnett/python-selfcompletion
|
||||
|
||||
Argument-level completion
|
||||
-------------------------
|
||||
|
||||
Argcomplete_ supports custom "completers". The documentation suggests adding
|
||||
the completer as an attribute of the argument parser action::
|
||||
|
||||
parser.add_argument("--env-var1").completer = EnvironCompleter
|
||||
|
||||
However, this doesn't fit the normal `Argh`-assisted workflow.
|
||||
It is recommended to use the :func:`~argh.decorators.arg` decorator::
|
||||
|
||||
@arg('--env-var1', completer=EnvironCompleter)
|
||||
def func(...):
|
||||
...
|
||||
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
||||
COMPLETION_ENABLED = False
|
||||
"""
|
||||
Dynamically set to `True` on load if argcomplete_ was successfully imported.
|
||||
"""
|
||||
|
||||
try:
|
||||
import argcomplete
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
COMPLETION_ENABLED = True
|
||||
|
||||
|
||||
__all__ = ['autocomplete', 'COMPLETION_ENABLED']
|
||||
|
||||
|
||||
logger = logging.getLogger(__package__)
|
||||
|
||||
|
||||
def autocomplete(parser):
|
||||
"""
|
||||
Adds support for shell completion via argcomplete_ by patching given
|
||||
`argparse.ArgumentParser` (sub)class.
|
||||
|
||||
If completion is not enabled, logs a debug-level message.
|
||||
"""
|
||||
if COMPLETION_ENABLED:
|
||||
argcomplete.autocomplete(parser)
|
||||
elif 'bash' in os.getenv('SHELL', ''):
|
||||
logger.debug('Bash completion not available. Install argcomplete.')
|
||||
@@ -1,103 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
import argparse
|
||||
|
||||
__all__ = (
|
||||
'ATTR_NAME', 'ATTR_ALIASES', 'ATTR_ARGS', 'ATTR_WRAPPED_EXCEPTIONS',
|
||||
'ATTR_WRAPPED_EXCEPTIONS_PROCESSOR', 'ATTR_EXPECTS_NAMESPACE_OBJECT',
|
||||
'PARSER_FORMATTER', 'DEFAULT_ARGUMENT_TEMPLATE', 'DEST_FUNCTION',
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Names of function attributes where Argh stores command behaviour
|
||||
#
|
||||
|
||||
#: explicit command name (differing from function name)
|
||||
ATTR_NAME = 'argh_name'
|
||||
|
||||
#: alternative command names
|
||||
ATTR_ALIASES = 'argh_aliases'
|
||||
|
||||
#: declared arguments
|
||||
ATTR_ARGS = 'argh_args'
|
||||
|
||||
#: list of exception classes that should be wrapped and printed as results
|
||||
ATTR_WRAPPED_EXCEPTIONS = 'argh_wrap_errors'
|
||||
|
||||
#: a function to preprocess the exception object when it is wrapped
|
||||
ATTR_WRAPPED_EXCEPTIONS_PROCESSOR = 'argh_wrap_errors_processor'
|
||||
|
||||
#: forcing argparse.Namespace object instead of signature introspection
|
||||
ATTR_EXPECTS_NAMESPACE_OBJECT = 'argh_expects_namespace_object'
|
||||
|
||||
#
|
||||
# Dest names in parser defaults
|
||||
#
|
||||
|
||||
#: dest name for a function mapped to given endpoint (goes to Namespace obj)
|
||||
DEST_FUNCTION = 'function'
|
||||
|
||||
#
|
||||
# Other library-wide stuff
|
||||
#
|
||||
|
||||
class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter,
|
||||
argparse.RawDescriptionHelpFormatter):
|
||||
def _expand_help(self, action):
|
||||
"""
|
||||
This method is copied verbatim from ArgumentDefaultsHelpFormatter with
|
||||
a couple of lines added just before the end. Reason: we need to
|
||||
`repr()` default values instead of simply inserting them as is.
|
||||
This helps notice, for example, an empty string as the default value;
|
||||
moreover, it prevents breaking argparse due to logical quirks inside
|
||||
of its formatters.
|
||||
|
||||
Ideally this could be achieved by simply defining
|
||||
:attr:`DEFAULT_ARGUMENT_TEMPLATE` as ``{default!r}`` but unfortunately
|
||||
argparse only supports the old printf syntax.
|
||||
"""
|
||||
params = dict(vars(action), prog=self._prog)
|
||||
for name in list(params):
|
||||
if params[name] is argparse.SUPPRESS:
|
||||
del params[name]
|
||||
for name in list(params):
|
||||
if hasattr(params[name], '__name__'):
|
||||
params[name] = params[name].__name__
|
||||
if params.get('choices') is not None:
|
||||
choices_str = ', '.join([str(c) for c in params['choices']])
|
||||
params['choices'] = choices_str
|
||||
|
||||
# XXX this is added in Argh vs. argparse.ArgumentDefaultsHelpFormatter
|
||||
# (avoiding empty strings, otherwise Argparse would die with
|
||||
# an IndexError in _format_action)
|
||||
#
|
||||
if 'default' in params:
|
||||
if params['default'] is None:
|
||||
params['default'] = '-'
|
||||
else:
|
||||
params['default'] = repr(params['default'])
|
||||
#
|
||||
# /
|
||||
|
||||
return self._get_help_string(action) % params
|
||||
|
||||
|
||||
#: Default formatter to be used in implicitly instantiated ArgumentParser.
|
||||
PARSER_FORMATTER = CustomFormatter
|
||||
|
||||
|
||||
DEFAULT_ARGUMENT_TEMPLATE = '%(default)s'
|
||||
"""
|
||||
Default template of argument help message (see issue #64).
|
||||
The template ``%(default)s`` is used by `argparse` to display the argument's
|
||||
default value.
|
||||
"""
|
||||
@@ -1,195 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Command decorators
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
"""
|
||||
from argh.constants import (ATTR_ALIASES, ATTR_ARGS, ATTR_NAME,
|
||||
ATTR_WRAPPED_EXCEPTIONS,
|
||||
ATTR_WRAPPED_EXCEPTIONS_PROCESSOR,
|
||||
ATTR_EXPECTS_NAMESPACE_OBJECT)
|
||||
|
||||
|
||||
__all__ = ['aliases', 'named', 'arg', 'wrap_errors', 'expects_obj']
|
||||
|
||||
|
||||
def named(new_name):
|
||||
"""
|
||||
Sets given string as command name instead of the function name.
|
||||
The string is used verbatim without further processing.
|
||||
|
||||
Usage::
|
||||
|
||||
@named('load')
|
||||
def do_load_some_stuff_and_keep_the_original_function_name(args):
|
||||
...
|
||||
|
||||
The resulting command will be available only as ``load``. To add aliases
|
||||
without renaming the command, check :func:`aliases`.
|
||||
|
||||
.. versionadded:: 0.19
|
||||
"""
|
||||
def wrapper(func):
|
||||
setattr(func, ATTR_NAME, new_name)
|
||||
return func
|
||||
return wrapper
|
||||
|
||||
|
||||
def aliases(*names):
|
||||
"""
|
||||
Defines alternative command name(s) for given function (along with its
|
||||
original name). Usage::
|
||||
|
||||
@aliases('co', 'check')
|
||||
def checkout(args):
|
||||
...
|
||||
|
||||
The resulting command will be available as ``checkout``, ``check`` and ``co``.
|
||||
|
||||
.. note::
|
||||
|
||||
This decorator only works with a recent version of argparse (see `Python
|
||||
issue 9324`_ and `Python rev 4c0426`_). Such version ships with
|
||||
**Python 3.2+** and may be available in other environments as a separate
|
||||
package. Argh does not issue warnings and simply ignores aliases if
|
||||
they are not supported. See :attr:`~argh.assembling.SUPPORTS_ALIASES`.
|
||||
|
||||
.. _Python issue 9324: http://bugs.python.org/issue9324
|
||||
.. _Python rev 4c0426: http://hg.python.org/cpython/rev/4c0426261148/
|
||||
|
||||
.. versionadded:: 0.19
|
||||
"""
|
||||
def wrapper(func):
|
||||
setattr(func, ATTR_ALIASES, names)
|
||||
return func
|
||||
return wrapper
|
||||
|
||||
|
||||
def arg(*args, **kwargs):
|
||||
"""
|
||||
Declares an argument for given function. Does not register the function
|
||||
anywhere, nor does it modify the function in any way.
|
||||
|
||||
The signature of the decorator matches that of
|
||||
:meth:`argparse.ArgumentParser.add_argument`, only some keywords are not
|
||||
required if they can be easily guessed (e.g. you don't have to specify type
|
||||
or action when an `int` or `bool` default value is supplied).
|
||||
|
||||
Typical use cases:
|
||||
|
||||
- In combination with :func:`expects_obj` (which is not recommended);
|
||||
- in combination with ordinary function signatures to add details that
|
||||
cannot be expressed with that syntax (e.g. help message).
|
||||
|
||||
Usage::
|
||||
|
||||
from argh import arg
|
||||
|
||||
@arg('path', help='path to the file to load')
|
||||
@arg('--format', choices=['yaml','json'])
|
||||
@arg('-v', '--verbosity', choices=range(0,3), default=2)
|
||||
def load(path, something=None, format='json', dry_run=False, verbosity=1):
|
||||
loaders = {'json': json.load, 'yaml': yaml.load}
|
||||
loader = loaders[args.format]
|
||||
data = loader(args.path)
|
||||
if not args.dry_run:
|
||||
if verbosity < 1:
|
||||
print('saving to the database')
|
||||
put_to_database(data)
|
||||
|
||||
In this example:
|
||||
|
||||
- `path` declaration is extended with `help`;
|
||||
- `format` declaration is extended with `choices`;
|
||||
- `dry_run` declaration is not duplicated;
|
||||
- `verbosity` is extended with `choices` and the default value is
|
||||
overridden. (If both function signature and `@arg` define a default
|
||||
value for an argument, `@arg` wins.)
|
||||
|
||||
.. note::
|
||||
|
||||
It is recommended to avoid using this decorator unless there's no way
|
||||
to tune the argument's behaviour or presentation using ordinary
|
||||
function signatures. Readability counts, don't repeat yourself.
|
||||
|
||||
"""
|
||||
def wrapper(func):
|
||||
declared_args = getattr(func, ATTR_ARGS, [])
|
||||
# The innermost decorator is called first but appears last in the code.
|
||||
# We need to preserve the expected order of positional arguments, so
|
||||
# the outermost decorator inserts its value before the innermost's:
|
||||
declared_args.insert(0, dict(option_strings=args, **kwargs))
|
||||
setattr(func, ATTR_ARGS, declared_args)
|
||||
return func
|
||||
return wrapper
|
||||
|
||||
|
||||
def wrap_errors(errors=None, processor=None, *args):
|
||||
"""
|
||||
Decorator. Wraps given exceptions into
|
||||
:class:`~argh.exceptions.CommandError`. Usage::
|
||||
|
||||
@wrap_errors([AssertionError])
|
||||
def foo(x=None, y=None):
|
||||
assert x or y, 'x or y must be specified'
|
||||
|
||||
If the assertion fails, its message will be correctly printed and the
|
||||
stack hidden. This helps to avoid boilerplate code.
|
||||
|
||||
:param errors:
|
||||
A list of exception classes to catch.
|
||||
:param processor:
|
||||
A callable that expects the exception object and returns a string.
|
||||
For example, this renders all wrapped errors in red colour::
|
||||
|
||||
from termcolor import colored
|
||||
|
||||
def failure(err):
|
||||
return colored(str(err), 'red')
|
||||
|
||||
@wrap_errors(processor=failure)
|
||||
def my_command(...):
|
||||
...
|
||||
|
||||
"""
|
||||
|
||||
def wrapper(func):
|
||||
if errors:
|
||||
setattr(func, ATTR_WRAPPED_EXCEPTIONS, errors)
|
||||
|
||||
if processor:
|
||||
setattr(func, ATTR_WRAPPED_EXCEPTIONS_PROCESSOR, processor)
|
||||
|
||||
return func
|
||||
return wrapper
|
||||
|
||||
|
||||
def expects_obj(func):
|
||||
"""
|
||||
Marks given function as expecting a namespace object.
|
||||
|
||||
Usage::
|
||||
|
||||
@arg('bar')
|
||||
@arg('--quux', default=123)
|
||||
@expects_obj
|
||||
def foo(args):
|
||||
yield args.bar, args.quux
|
||||
|
||||
This is equivalent to::
|
||||
|
||||
def foo(bar, quux=123):
|
||||
yield bar, quux
|
||||
|
||||
In most cases you don't need this decorator.
|
||||
"""
|
||||
setattr(func, ATTR_EXPECTS_NAMESPACE_OBJECT, True)
|
||||
return func
|
||||
@@ -1,382 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Dispatching
|
||||
~~~~~~~~~~~
|
||||
"""
|
||||
import argparse
|
||||
import sys
|
||||
from types import GeneratorType
|
||||
|
||||
from argh import compat, io
|
||||
from argh.constants import (
|
||||
ATTR_WRAPPED_EXCEPTIONS,
|
||||
ATTR_WRAPPED_EXCEPTIONS_PROCESSOR,
|
||||
ATTR_EXPECTS_NAMESPACE_OBJECT,
|
||||
PARSER_FORMATTER,
|
||||
DEST_FUNCTION,
|
||||
)
|
||||
from argh.completion import autocomplete
|
||||
from argh.assembling import add_commands, set_default_command
|
||||
from argh.exceptions import DispatchingError, CommandError
|
||||
from argh.utils import get_arg_spec
|
||||
|
||||
|
||||
__all__ = ['dispatch', 'dispatch_command', 'dispatch_commands',
|
||||
'PARSER_FORMATTER', 'EntryPoint']
|
||||
|
||||
|
||||
class ArghNamespace(argparse.Namespace):
|
||||
"""
|
||||
A namespace object which collects the stack of functions (the
|
||||
:attr:`~argh.constants.DEST_FUNCTION` arguments passed to it via
|
||||
parser's defaults).
|
||||
"""
|
||||
def __init__(self, *args, **kw):
|
||||
super(ArghNamespace, self).__init__(*args, **kw)
|
||||
self._functions_stack = []
|
||||
|
||||
def __setattr__(self, k, v):
|
||||
if k == DEST_FUNCTION:
|
||||
# don't register the function under DEST_FUNCTION name.
|
||||
# If `ArgumentParser.parse_known_args()` sees that we already have
|
||||
# such attribute, it skips it. However, it goes from the topmost
|
||||
# parser to subparsers. We need the function mapped to the
|
||||
# subparser. So we fool the `ArgumentParser` and pretend that we
|
||||
# didn't get a DEST_FUNCTION attribute; however, in fact we collect
|
||||
# all its values in a stack. The last item in the stack would be
|
||||
# the function mapped to the innermost parser — the one we need.
|
||||
self._functions_stack.append(v)
|
||||
else:
|
||||
super(ArghNamespace, self).__setattr__(k, v)
|
||||
|
||||
def get_function(self):
|
||||
return self._functions_stack[-1]
|
||||
|
||||
|
||||
def dispatch(parser, argv=None, add_help_command=True,
|
||||
completion=True, pre_call=None,
|
||||
output_file=sys.stdout, errors_file=sys.stderr,
|
||||
raw_output=False, namespace=None,
|
||||
skip_unknown_args=False):
|
||||
"""
|
||||
Parses given list of arguments using given parser, calls the relevant
|
||||
function and prints the result.
|
||||
|
||||
The target function should expect one positional argument: the
|
||||
:class:`argparse.Namespace` object. However, if the function is decorated with
|
||||
:func:`~argh.decorators.plain_signature`, the positional and named
|
||||
arguments from the namespace object are passed to the function instead
|
||||
of the object itself.
|
||||
|
||||
:param parser:
|
||||
|
||||
the ArgumentParser instance.
|
||||
|
||||
:param argv:
|
||||
|
||||
a list of strings representing the arguments. If `None`, ``sys.argv``
|
||||
is used instead. Default is `None`.
|
||||
|
||||
:param add_help_command:
|
||||
|
||||
if `True`, converts first positional argument "help" to a keyword
|
||||
argument so that ``help foo`` becomes ``foo --help`` and displays usage
|
||||
information for "foo". Default is `True`.
|
||||
|
||||
:param output_file:
|
||||
|
||||
A file-like object for output. If `None`, the resulting lines are
|
||||
collected and returned as a string. Default is ``sys.stdout``.
|
||||
|
||||
:param errors_file:
|
||||
|
||||
Same as `output_file` but for ``sys.stderr``.
|
||||
|
||||
:param raw_output:
|
||||
|
||||
If `True`, results are written to the output file raw, without adding
|
||||
whitespaces or newlines between yielded strings. Default is `False`.
|
||||
|
||||
:param completion:
|
||||
|
||||
If `True`, shell tab completion is enabled. Default is `True`. (You
|
||||
will also need to install it.) See :mod:`argh.completion`.
|
||||
|
||||
:param skip_unknown_args:
|
||||
|
||||
If `True`, unknown arguments do not cause an error
|
||||
(`ArgumentParser.parse_known_args` is used).
|
||||
|
||||
:param namespace:
|
||||
|
||||
An `argparse.Namespace`-like object. By default an
|
||||
:class:`ArghNamespace` object is used. Please note that support for
|
||||
combined default and nested functions may be broken if a different
|
||||
type of object is forced.
|
||||
|
||||
By default the exceptions are not wrapped and will propagate. The only
|
||||
exception that is always wrapped is :class:`~argh.exceptions.CommandError`
|
||||
which is interpreted as an expected event so the traceback is hidden.
|
||||
You can also mark arbitrary exceptions as "wrappable" by using the
|
||||
:func:`~argh.decorators.wrap_errors` decorator.
|
||||
"""
|
||||
if completion:
|
||||
autocomplete(parser)
|
||||
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
|
||||
if add_help_command:
|
||||
if argv and argv[0] == 'help':
|
||||
argv.pop(0)
|
||||
argv.append('--help')
|
||||
|
||||
if skip_unknown_args:
|
||||
parse_args = parser.parse_known_args
|
||||
else:
|
||||
parse_args = parser.parse_args
|
||||
|
||||
if not namespace:
|
||||
namespace = ArghNamespace()
|
||||
|
||||
# this will raise SystemExit if parsing fails
|
||||
namespace_obj = parse_args(argv, namespace=namespace)
|
||||
|
||||
function = _get_function_from_namespace_obj(namespace_obj)
|
||||
|
||||
if function:
|
||||
lines = _execute_command(function, namespace_obj, errors_file,
|
||||
pre_call=pre_call)
|
||||
else:
|
||||
# no commands declared, can't dispatch; display help message
|
||||
lines = [parser.format_usage()]
|
||||
|
||||
if output_file is None:
|
||||
# user wants a string; we create an internal temporary file-like object
|
||||
# and will return its contents as a string
|
||||
if sys.version_info < (3,0):
|
||||
f = compat.BytesIO()
|
||||
else:
|
||||
f = compat.StringIO()
|
||||
else:
|
||||
# normally this is stdout; can be any file
|
||||
f = output_file
|
||||
|
||||
for line in lines:
|
||||
# print the line as soon as it is generated to ensure that it is
|
||||
# displayed to the user before anything else happens, e.g.
|
||||
# raw_input() is called
|
||||
|
||||
io.dump(line, f)
|
||||
if not raw_output:
|
||||
# in most cases user wants one message per line
|
||||
io.dump('\n', f)
|
||||
|
||||
if output_file is None:
|
||||
# user wanted a string; return contents of our temporary file-like obj
|
||||
f.seek(0)
|
||||
return f.read()
|
||||
|
||||
|
||||
def _get_function_from_namespace_obj(namespace_obj):
|
||||
if isinstance(namespace_obj, ArghNamespace):
|
||||
# our special namespace object keeps the stack of assigned functions
|
||||
try:
|
||||
function = namespace_obj.get_function()
|
||||
except (AttributeError, IndexError):
|
||||
return None
|
||||
else:
|
||||
# a custom (probably vanilla) namespace object keeps the last assigned
|
||||
# function; this may be wrong but at least something may work
|
||||
if not hasattr(namespace_obj, DEST_FUNCTION):
|
||||
return None
|
||||
function = getattr(namespace_obj, DEST_FUNCTION)
|
||||
|
||||
if not function or not hasattr(function, '__call__'):
|
||||
return None
|
||||
|
||||
return function
|
||||
|
||||
|
||||
def _execute_command(function, namespace_obj, errors_file, pre_call=None):
|
||||
"""
|
||||
Assumes that `function` is a callable. Tries different approaches
|
||||
to call it (with `namespace_obj` or with ordinary signature).
|
||||
Yields the results line by line.
|
||||
|
||||
If :class:`~argh.exceptions.CommandError` is raised, its message is
|
||||
appended to the results (i.e. yielded by the generator as a string).
|
||||
All other exceptions propagate unless marked as wrappable
|
||||
by :func:`wrap_errors`.
|
||||
"""
|
||||
if pre_call: # XXX undocumented because I'm unsure if it's OK
|
||||
# Actually used in real projects:
|
||||
# * https://google.com/search?q=argh+dispatch+pre_call
|
||||
# * https://github.com/neithere/argh/issues/63
|
||||
pre_call(namespace_obj)
|
||||
|
||||
# the function is nested to catch certain exceptions (see below)
|
||||
def _call():
|
||||
# Actually call the function
|
||||
if getattr(function, ATTR_EXPECTS_NAMESPACE_OBJECT, False):
|
||||
result = function(namespace_obj)
|
||||
else:
|
||||
# namespace -> dictionary
|
||||
_flat_key = lambda key: key.replace('-', '_')
|
||||
all_input = dict((_flat_key(k), v)
|
||||
for k,v in vars(namespace_obj).items())
|
||||
|
||||
# filter the namespace variables so that only those expected
|
||||
# by the actual function will pass
|
||||
|
||||
spec = get_arg_spec(function)
|
||||
|
||||
positional = [all_input[k] for k in spec.args]
|
||||
kwonly = getattr(spec, 'kwonlyargs', [])
|
||||
keywords = dict((k, all_input[k]) for k in kwonly)
|
||||
|
||||
# *args
|
||||
if spec.varargs:
|
||||
positional += getattr(namespace_obj, spec.varargs)
|
||||
|
||||
# **kwargs
|
||||
varkw = getattr(spec, 'varkw', getattr(spec, 'keywords', []))
|
||||
if varkw:
|
||||
not_kwargs = [DEST_FUNCTION] + spec.args + [spec.varargs] + kwonly
|
||||
for k in vars(namespace_obj):
|
||||
if k.startswith('_') or k in not_kwargs:
|
||||
continue
|
||||
keywords[k] = getattr(namespace_obj, k)
|
||||
|
||||
result = function(*positional, **keywords)
|
||||
|
||||
# Yield the results
|
||||
if isinstance(result, (GeneratorType, list, tuple)):
|
||||
# yield each line ASAP, convert CommandError message to a line
|
||||
for line in result:
|
||||
yield line
|
||||
else:
|
||||
# yield non-empty non-iterable result as a single line
|
||||
if result is not None:
|
||||
yield result
|
||||
|
||||
wrappable_exceptions = [CommandError]
|
||||
wrappable_exceptions += getattr(function, ATTR_WRAPPED_EXCEPTIONS, [])
|
||||
|
||||
try:
|
||||
result = _call()
|
||||
for line in result:
|
||||
yield line
|
||||
except tuple(wrappable_exceptions) as e:
|
||||
processor = getattr(function, ATTR_WRAPPED_EXCEPTIONS_PROCESSOR,
|
||||
lambda e: '{0.__class__.__name__}: {0}'.format(e))
|
||||
|
||||
errors_file.write(compat.text_type(processor(e)))
|
||||
errors_file.write('\n')
|
||||
|
||||
|
||||
def dispatch_command(function, *args, **kwargs):
|
||||
"""
|
||||
A wrapper for :func:`dispatch` that creates a one-command parser.
|
||||
Uses :attr:`PARSER_FORMATTER`.
|
||||
|
||||
This::
|
||||
|
||||
dispatch_command(foo)
|
||||
|
||||
...is a shortcut for::
|
||||
|
||||
parser = ArgumentParser()
|
||||
set_default_command(parser, foo)
|
||||
dispatch(parser)
|
||||
|
||||
This function can be also used as a decorator.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(formatter_class=PARSER_FORMATTER)
|
||||
set_default_command(parser, function)
|
||||
dispatch(parser, *args, **kwargs)
|
||||
|
||||
|
||||
def dispatch_commands(functions, *args, **kwargs):
|
||||
"""
|
||||
A wrapper for :func:`dispatch` that creates a parser, adds commands to
|
||||
the parser and dispatches them.
|
||||
Uses :attr:`PARSER_FORMATTER`.
|
||||
|
||||
This::
|
||||
|
||||
dispatch_commands([foo, bar])
|
||||
|
||||
...is a shortcut for::
|
||||
|
||||
parser = ArgumentParser()
|
||||
add_commands(parser, [foo, bar])
|
||||
dispatch(parser)
|
||||
|
||||
"""
|
||||
parser = argparse.ArgumentParser(formatter_class=PARSER_FORMATTER)
|
||||
add_commands(parser, functions)
|
||||
dispatch(parser, *args, **kwargs)
|
||||
|
||||
|
||||
class EntryPoint(object):
|
||||
"""
|
||||
An object to which functions can be attached and then dispatched.
|
||||
|
||||
When called with an argument, the argument (a function) is registered
|
||||
at this entry point as a command.
|
||||
|
||||
When called without an argument, dispatching is triggered with all
|
||||
previously registered commands.
|
||||
|
||||
Usage::
|
||||
|
||||
from argh import EntryPoint
|
||||
|
||||
app = EntryPoint('main', dict(description='This is a cool app'))
|
||||
|
||||
@app
|
||||
def ls():
|
||||
for i in range(10):
|
||||
print i
|
||||
|
||||
@app
|
||||
def greet():
|
||||
print 'hello'
|
||||
|
||||
if __name__ == '__main__':
|
||||
app()
|
||||
|
||||
"""
|
||||
def __init__(self, name=None, parser_kwargs=None):
|
||||
self.name = name or 'unnamed'
|
||||
self.commands = []
|
||||
self.parser_kwargs = parser_kwargs or {}
|
||||
|
||||
def __call__(self, f=None):
|
||||
if f:
|
||||
self._register_command(f)
|
||||
return f
|
||||
|
||||
return self._dispatch()
|
||||
|
||||
def _register_command(self, f):
|
||||
self.commands.append(f)
|
||||
|
||||
def _dispatch(self):
|
||||
if not self.commands:
|
||||
raise DispatchingError('no commands for entry point "{0}"'
|
||||
.format(self.name))
|
||||
|
||||
parser = argparse.ArgumentParser(**self.parser_kwargs)
|
||||
add_commands(parser, self.commands)
|
||||
dispatch(parser)
|
||||
@@ -1,56 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Exceptions
|
||||
~~~~~~~~~~
|
||||
"""
|
||||
class AssemblingError(Exception):
|
||||
"""
|
||||
Raised if the parser could not be configured due to malformed
|
||||
or conflicting command declarations.
|
||||
"""
|
||||
|
||||
|
||||
class DispatchingError(Exception):
|
||||
"""
|
||||
Raised if the dispatching could not be completed due to misconfiguration
|
||||
which could not be determined on an earlier stage.
|
||||
"""
|
||||
|
||||
|
||||
class CommandError(Exception):
|
||||
"""
|
||||
Intended to be raised from within a command. The dispatcher wraps this
|
||||
exception by default and prints its message without traceback.
|
||||
|
||||
Useful for print-and-exit tasks when you expect a failure and don't want
|
||||
to startle the ordinary user by the cryptic output.
|
||||
|
||||
Consider the following example::
|
||||
|
||||
def foo(args):
|
||||
try:
|
||||
...
|
||||
except KeyError as e:
|
||||
print(u'Could not fetch item: {0}'.format(e))
|
||||
return
|
||||
|
||||
It is exactly the same as::
|
||||
|
||||
def bar(args):
|
||||
try:
|
||||
...
|
||||
except KeyError as e:
|
||||
raise CommandError(u'Could not fetch item: {0}'.format(e))
|
||||
|
||||
This exception can be safely used in both print-style and yield-style
|
||||
commands (see :doc:`tutorial`).
|
||||
"""
|
||||
@@ -1,64 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Helpers
|
||||
~~~~~~~
|
||||
"""
|
||||
import argparse
|
||||
|
||||
from argh.completion import autocomplete
|
||||
from argh.assembling import add_commands, set_default_command
|
||||
from argh.dispatching import PARSER_FORMATTER, ArghNamespace, dispatch
|
||||
|
||||
|
||||
__all__ = ['ArghParser']
|
||||
|
||||
|
||||
class ArghParser(argparse.ArgumentParser):
|
||||
"""
|
||||
A subclass of :class:`ArgumentParser` with support for and a couple
|
||||
of convenience methods.
|
||||
|
||||
All methods are but wrappers for stand-alone functions
|
||||
:func:`~argh.assembling.add_commands`,
|
||||
:func:`~argh.completion.autocomplete` and
|
||||
:func:`~argh.dispatching.dispatch`.
|
||||
|
||||
Uses :attr:`~argh.dispatching.PARSER_FORMATTER`.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs.setdefault('formatter_class', PARSER_FORMATTER)
|
||||
super(ArghParser, self).__init__(*args, **kwargs)
|
||||
|
||||
def set_default_command(self, *args, **kwargs):
|
||||
"Wrapper for :func:`~argh.assembling.set_default_command`."
|
||||
return set_default_command(self, *args, **kwargs)
|
||||
|
||||
def add_commands(self, *args, **kwargs):
|
||||
"Wrapper for :func:`~argh.assembling.add_commands`."
|
||||
return add_commands(self, *args, **kwargs)
|
||||
|
||||
def autocomplete(self):
|
||||
"Wrapper for :func:`~argh.completion.autocomplete`."
|
||||
return autocomplete(self)
|
||||
|
||||
def dispatch(self, *args, **kwargs):
|
||||
"Wrapper for :func:`~argh.dispatching.dispatch`."
|
||||
return dispatch(self, *args, **kwargs)
|
||||
|
||||
def parse_args(self, args=None, namespace=None):
|
||||
"""
|
||||
Wrapper for :meth:`argparse.ArgumentParser.parse_args`. If `namespace`
|
||||
is not defined, :class:`argh.dispatching.ArghNamespace` is used.
|
||||
This is required for functions to be properly used as commands.
|
||||
"""
|
||||
namespace = namespace or ArghNamespace()
|
||||
return super(ArghParser, self).parse_args(args, namespace)
|
||||
@@ -1,84 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Interaction
|
||||
~~~~~~~~~~~
|
||||
"""
|
||||
from argh.compat import text_type
|
||||
from argh.io import safe_input
|
||||
|
||||
|
||||
__all__ = ['confirm', 'safe_input']
|
||||
|
||||
|
||||
def confirm(action, default=None, skip=False):
|
||||
"""
|
||||
A shortcut for typical confirmation prompt.
|
||||
|
||||
:param action:
|
||||
|
||||
a string describing the action, e.g. "Apply changes". A question mark
|
||||
will be appended.
|
||||
|
||||
:param default:
|
||||
|
||||
`bool` or `None`. Determines what happens when user hits :kbd:`Enter`
|
||||
without typing in a choice. If `True`, default choice is "yes". If
|
||||
`False`, it is "no". If `None` the prompt keeps reappearing until user
|
||||
types in a choice (not necessarily acceptable) or until the number of
|
||||
iteration reaches the limit. Default is `None`.
|
||||
|
||||
:param skip:
|
||||
|
||||
`bool`; if `True`, no interactive prompt is used and default choice is
|
||||
returned (useful for batch mode). Default is `False`.
|
||||
|
||||
Usage::
|
||||
|
||||
def delete(key, silent=False):
|
||||
item = db.get(Item, args.key)
|
||||
if confirm('Delete '+item.title, default=True, skip=silent):
|
||||
item.delete()
|
||||
print('Item deleted.')
|
||||
else:
|
||||
print('Operation cancelled.')
|
||||
|
||||
Returns `None` on `KeyboardInterrupt` event.
|
||||
"""
|
||||
MAX_ITERATIONS = 3
|
||||
if skip:
|
||||
return default
|
||||
else:
|
||||
defaults = {
|
||||
None: ('y','n'),
|
||||
True: ('Y','n'),
|
||||
False: ('y','N'),
|
||||
}
|
||||
y, n = defaults[default]
|
||||
prompt = text_type('{action}? ({y}/{n})').format(**locals())
|
||||
choice = None
|
||||
try:
|
||||
if default is None:
|
||||
cnt = 1
|
||||
while not choice and cnt < MAX_ITERATIONS:
|
||||
choice = safe_input(prompt)
|
||||
cnt += 1
|
||||
else:
|
||||
choice = safe_input(prompt)
|
||||
except KeyboardInterrupt:
|
||||
return None
|
||||
if choice in ('yes', 'y', 'Y'):
|
||||
return True
|
||||
if choice in ('no', 'n', 'N'):
|
||||
return False
|
||||
if default is not None:
|
||||
return default
|
||||
return None
|
||||
@@ -1,105 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Output Processing
|
||||
~~~~~~~~~~~~~~~~~
|
||||
"""
|
||||
import locale
|
||||
import sys
|
||||
|
||||
from argh import compat
|
||||
|
||||
|
||||
__all__ = ['dump', 'encode_output', 'safe_input']
|
||||
|
||||
|
||||
def _input(prompt):
|
||||
# this function can be mocked up in tests
|
||||
if sys.version_info < (3,0):
|
||||
return raw_input(prompt)
|
||||
else:
|
||||
return input(prompt)
|
||||
|
||||
|
||||
def safe_input(prompt):
|
||||
"""
|
||||
Prompts user for input. Correctly handles prompt message encoding.
|
||||
"""
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
if isinstance(prompt, compat.text_type):
|
||||
# Python 2.x: unicode → bytes
|
||||
encoding = locale.getpreferredencoding() or 'utf-8'
|
||||
prompt = prompt.encode(encoding)
|
||||
else:
|
||||
if not isinstance(prompt, compat.text_type):
|
||||
# Python 3.x: bytes → unicode
|
||||
prompt = prompt.decode()
|
||||
|
||||
return _input(prompt)
|
||||
|
||||
|
||||
def encode_output(value, output_file):
|
||||
"""
|
||||
Encodes given value so it can be written to given file object.
|
||||
|
||||
Value may be Unicode, binary string or any other data type.
|
||||
|
||||
The exact behaviour depends on the Python version:
|
||||
|
||||
Python 3.x
|
||||
|
||||
`sys.stdout` is a `_io.TextIOWrapper` instance that accepts `str`
|
||||
(unicode) and breaks on `bytes`.
|
||||
|
||||
It is OK to simply assume that everything is Unicode unless special
|
||||
handling is introduced in the client code.
|
||||
|
||||
Thus, no additional processing is performed.
|
||||
|
||||
Python 2.x
|
||||
|
||||
`sys.stdout` is a file-like object that accepts `str` (bytes)
|
||||
and breaks when `unicode` is passed to `sys.stdout.write()`.
|
||||
|
||||
We can expect both Unicode and bytes. They need to be encoded so as
|
||||
to match the file object encoding.
|
||||
|
||||
The output is binary if the object doesn't explicitly require Unicode.
|
||||
|
||||
"""
|
||||
if sys.version_info > (3,0):
|
||||
# Python 3: whatever → unicode
|
||||
return compat.text_type(value)
|
||||
else:
|
||||
# Python 2: handle special cases
|
||||
stream_encoding = getattr(output_file, 'encoding', None)
|
||||
if stream_encoding:
|
||||
if stream_encoding.upper() == 'UTF-8':
|
||||
return compat.text_type(value)
|
||||
else:
|
||||
return value.encode(stream_encoding, 'ignore')
|
||||
else:
|
||||
# no explicit encoding requirements; force binary
|
||||
if isinstance(value, compat.text_type):
|
||||
# unicode → binary
|
||||
return value.encode('utf-8')
|
||||
else:
|
||||
return str(value)
|
||||
|
||||
|
||||
def dump(raw_data, output_file):
|
||||
"""
|
||||
Writes given line to given output file.
|
||||
See :func:`encode_output` for details.
|
||||
"""
|
||||
data = encode_output(raw_data, output_file)
|
||||
output_file.write(data)
|
||||
@@ -1,55 +0,0 @@
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright © 2010—2014 Andrey Mikhaylenko and contributors
|
||||
#
|
||||
# This file is part of Argh.
|
||||
#
|
||||
# Argh is free software under terms of the GNU Lesser
|
||||
# General Public License version 3 (LGPLv3) as published by the Free
|
||||
# Software Foundation. See the file README.rst for copying conditions.
|
||||
#
|
||||
"""
|
||||
Utilities
|
||||
~~~~~~~~~
|
||||
"""
|
||||
import argparse
|
||||
import inspect
|
||||
|
||||
from argh import compat
|
||||
|
||||
|
||||
def get_subparsers(parser, create=False):
|
||||
"""
|
||||
Returns the :class:`argparse._SubParsersAction` instance for given
|
||||
:class:`ArgumentParser` instance as would have been returned by
|
||||
:meth:`ArgumentParser.add_subparsers`. The problem with the latter is that
|
||||
it only works once and raises an exception on the second attempt, and the
|
||||
public API seems to lack a method to get *existing* subparsers.
|
||||
|
||||
:param create:
|
||||
If `True`, creates the subparser if it does not exist. Default if
|
||||
`False`.
|
||||
|
||||
"""
|
||||
# note that ArgumentParser._subparsers is *not* what is returned by
|
||||
# ArgumentParser.add_subparsers().
|
||||
if parser._subparsers:
|
||||
actions = [a for a in parser._actions
|
||||
if isinstance(a, argparse._SubParsersAction)]
|
||||
assert len(actions) == 1
|
||||
return actions[0]
|
||||
else:
|
||||
if create:
|
||||
return parser.add_subparsers()
|
||||
|
||||
|
||||
def get_arg_spec(function):
|
||||
"""
|
||||
Returns argument specification for given function. Omits special
|
||||
arguments of instance methods (`self`) and static methods (usually `cls`
|
||||
or something like this).
|
||||
"""
|
||||
spec = compat.getargspec(function)
|
||||
if inspect.ismethod(function):
|
||||
spec = spec._replace(args=spec.args[1:])
|
||||
return spec
|
||||
@@ -1,101 +0,0 @@
|
||||
Metadata-Version: 1.1
|
||||
Name: blinker
|
||||
Version: 1.4
|
||||
Summary: Fast, simple object-to-object and broadcast signaling
|
||||
Home-page: http://pythonhosted.org/blinker/
|
||||
Author: Jason Kirtland
|
||||
Author-email: jek@discorporate.us
|
||||
License: MIT License
|
||||
Description: [](https://travis-ci.org/jek/blinker)
|
||||
|
||||
|
||||
# Blinker
|
||||
|
||||
Blinker provides a fast dispatching system that allows any number of
|
||||
interested parties to subscribe to events, or "signals".
|
||||
|
||||
Signal receivers can subscribe to specific senders or receive signals
|
||||
sent by any sender.
|
||||
|
||||
>>> from blinker import signal
|
||||
>>> started = signal('round-started')
|
||||
>>> def each(round):
|
||||
... print "Round %s!" % round
|
||||
...
|
||||
>>> started.connect(each)
|
||||
|
||||
>>> def round_two(round):
|
||||
... print "This is round two."
|
||||
...
|
||||
>>> started.connect(round_two, sender=2)
|
||||
|
||||
>>> for round in range(1, 4):
|
||||
... started.send(round)
|
||||
...
|
||||
Round 1!
|
||||
Round 2!
|
||||
This is round two.
|
||||
Round 3!
|
||||
|
||||
See the [Blinker documentation](https://pythonhosted.org/blinker/) for more information.
|
||||
|
||||
## Requirements
|
||||
|
||||
Blinker requires Python 2.4 or higher, Python 3.0 or higher, or Jython 2.5 or higher.
|
||||
|
||||
## Changelog Summary
|
||||
|
||||
1.3 (July 3, 2013)
|
||||
|
||||
- The global signal stash behind blinker.signal() is now backed by a
|
||||
regular name-to-Signal dictionary. Previously, weak references were
|
||||
held in the mapping and ephemeral usage in code like
|
||||
``signal('foo').connect(...)`` could have surprising program behavior
|
||||
depending on import order of modules.
|
||||
- blinker.Namespace is now built on a regular dict. Use
|
||||
blinker.WeakNamespace for the older, weak-referencing behavior.
|
||||
- Signal.connect('text-sender') uses an alternate hashing strategy to
|
||||
avoid sharp edges in text identity.
|
||||
|
||||
1.2 (October 26, 2011)
|
||||
|
||||
- Added Signal.receiver_connected and Signal.receiver_disconnected
|
||||
per-Signal signals.
|
||||
- Deprecated the global 'receiver_connected' signal.
|
||||
- Verified Python 3.2 support (no changes needed!)
|
||||
|
||||
1.1 (July 21, 2010)
|
||||
|
||||
- Added ``@signal.connect_via(sender)`` decorator
|
||||
- Added ``signal.connected_to`` shorthand name for the
|
||||
``temporarily_connected_to`` context manager.
|
||||
|
||||
1.0 (March 28, 2010)
|
||||
|
||||
- Python 3.x compatibility
|
||||
|
||||
0.9 (February 26, 2010)
|
||||
|
||||
- Sphinx docs, project website
|
||||
- Added ``with a_signal.temporarily_connected_to(receiver): ...`` support
|
||||
|
||||
Keywords: signal emit events broadcast
|
||||
Platform: UNKNOWN
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Operating System :: OS Independent
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.4
|
||||
Classifier: Programming Language :: Python :: 2.5
|
||||
Classifier: Programming Language :: Python :: 2.6
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.0
|
||||
Classifier: Programming Language :: Python :: 3.1
|
||||
Classifier: Programming Language :: Python :: 3.2
|
||||
Classifier: Programming Language :: Python :: 3.3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Topic :: Software Development :: Libraries
|
||||
Classifier: Topic :: Utilities
|
||||
@@ -1,49 +0,0 @@
|
||||
AUTHORS
|
||||
CHANGES
|
||||
LICENSE
|
||||
MANIFEST.in
|
||||
README.md
|
||||
setup.cfg
|
||||
setup.py
|
||||
blinker/__init__.py
|
||||
blinker/_saferef.py
|
||||
blinker/_utilities.py
|
||||
blinker/base.py
|
||||
blinker.egg-info/PKG-INFO
|
||||
blinker.egg-info/SOURCES.txt
|
||||
blinker.egg-info/dependency_links.txt
|
||||
blinker.egg-info/top_level.txt
|
||||
docs/html/genindex.html
|
||||
docs/html/index.html
|
||||
docs/html/objects.inv
|
||||
docs/html/search.html
|
||||
docs/html/searchindex.js
|
||||
docs/html/_sources/index.txt
|
||||
docs/html/_static/basic.css
|
||||
docs/html/_static/blinker-named.png
|
||||
docs/html/_static/blinker64.png
|
||||
docs/html/_static/comment-bright.png
|
||||
docs/html/_static/comment-close.png
|
||||
docs/html/_static/comment.png
|
||||
docs/html/_static/doctools.js
|
||||
docs/html/_static/down-pressed.png
|
||||
docs/html/_static/down.png
|
||||
docs/html/_static/file.png
|
||||
docs/html/_static/flasky.css
|
||||
docs/html/_static/jquery.js
|
||||
docs/html/_static/minus.png
|
||||
docs/html/_static/plus.png
|
||||
docs/html/_static/pygments.css
|
||||
docs/html/_static/searchtools.js
|
||||
docs/html/_static/underscore.js
|
||||
docs/html/_static/up-pressed.png
|
||||
docs/html/_static/up.png
|
||||
docs/html/_static/websupport.js
|
||||
docs/source/conf.py
|
||||
docs/source/index.rst
|
||||
docs/source/_themes/flask_theme_support.py
|
||||
docs/text/index.txt
|
||||
tests/test_context.py
|
||||
tests/test_saferef.py
|
||||
tests/test_signals.py
|
||||
tests/test_utilities.py
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
../blinker/__init__.py
|
||||
../blinker/__pycache__/__init__.cpython-36.pyc
|
||||
../blinker/__pycache__/_saferef.cpython-36.pyc
|
||||
../blinker/__pycache__/_utilities.cpython-36.pyc
|
||||
../blinker/__pycache__/base.cpython-36.pyc
|
||||
../blinker/_saferef.py
|
||||
../blinker/_utilities.py
|
||||
../blinker/base.py
|
||||
PKG-INFO
|
||||
SOURCES.txt
|
||||
dependency_links.txt
|
||||
top_level.txt
|
||||
@@ -1 +0,0 @@
|
||||
blinker
|
||||
@@ -1,22 +0,0 @@
|
||||
from blinker.base import (
|
||||
ANY,
|
||||
NamedSignal,
|
||||
Namespace,
|
||||
Signal,
|
||||
WeakNamespace,
|
||||
receiver_connected,
|
||||
signal,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
'ANY',
|
||||
'NamedSignal',
|
||||
'Namespace',
|
||||
'Signal',
|
||||
'WeakNamespace',
|
||||
'receiver_connected',
|
||||
'signal',
|
||||
]
|
||||
|
||||
|
||||
__version__ = '1.4'
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,234 +0,0 @@
|
||||
# extracted from Louie, http://pylouie.org/
|
||||
# updated for Python 3
|
||||
#
|
||||
# Copyright (c) 2006 Patrick K. O'Brien, Mike C. Fletcher,
|
||||
# Matthew R. Scott
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
"""Refactored 'safe reference from dispatcher.py"""
|
||||
|
||||
import operator
|
||||
import sys
|
||||
import traceback
|
||||
import weakref
|
||||
|
||||
|
||||
try:
|
||||
callable
|
||||
except NameError:
|
||||
def callable(object):
|
||||
return hasattr(object, '__call__')
|
||||
|
||||
|
||||
if sys.version_info < (3,):
|
||||
get_self = operator.attrgetter('im_self')
|
||||
get_func = operator.attrgetter('im_func')
|
||||
else:
|
||||
get_self = operator.attrgetter('__self__')
|
||||
get_func = operator.attrgetter('__func__')
|
||||
|
||||
|
||||
def safe_ref(target, on_delete=None):
|
||||
"""Return a *safe* weak reference to a callable target.
|
||||
|
||||
- ``target``: The object to be weakly referenced, if it's a bound
|
||||
method reference, will create a BoundMethodWeakref, otherwise
|
||||
creates a simple weakref.
|
||||
|
||||
- ``on_delete``: If provided, will have a hard reference stored to
|
||||
the callable to be called after the safe reference goes out of
|
||||
scope with the reference object, (either a weakref or a
|
||||
BoundMethodWeakref) as argument.
|
||||
"""
|
||||
try:
|
||||
im_self = get_self(target)
|
||||
except AttributeError:
|
||||
if callable(on_delete):
|
||||
return weakref.ref(target, on_delete)
|
||||
else:
|
||||
return weakref.ref(target)
|
||||
else:
|
||||
if im_self is not None:
|
||||
# Turn a bound method into a BoundMethodWeakref instance.
|
||||
# Keep track of these instances for lookup by disconnect().
|
||||
assert hasattr(target, 'im_func') or hasattr(target, '__func__'), (
|
||||
"safe_ref target %r has im_self, but no im_func, "
|
||||
"don't know how to create reference" % target)
|
||||
reference = BoundMethodWeakref(target=target, on_delete=on_delete)
|
||||
return reference
|
||||
|
||||
|
||||
class BoundMethodWeakref(object):
|
||||
"""'Safe' and reusable weak references to instance methods.
|
||||
|
||||
BoundMethodWeakref objects provide a mechanism for referencing a
|
||||
bound method without requiring that the method object itself
|
||||
(which is normally a transient object) is kept alive. Instead,
|
||||
the BoundMethodWeakref object keeps weak references to both the
|
||||
object and the function which together define the instance method.
|
||||
|
||||
Attributes:
|
||||
|
||||
- ``key``: The identity key for the reference, calculated by the
|
||||
class's calculate_key method applied to the target instance method.
|
||||
|
||||
- ``deletion_methods``: Sequence of callable objects taking single
|
||||
argument, a reference to this object which will be called when
|
||||
*either* the target object or target function is garbage
|
||||
collected (i.e. when this object becomes invalid). These are
|
||||
specified as the on_delete parameters of safe_ref calls.
|
||||
|
||||
- ``weak_self``: Weak reference to the target object.
|
||||
|
||||
- ``weak_func``: Weak reference to the target function.
|
||||
|
||||
Class Attributes:
|
||||
|
||||
- ``_all_instances``: Class attribute pointing to all live
|
||||
BoundMethodWeakref objects indexed by the class's
|
||||
calculate_key(target) method applied to the target objects.
|
||||
This weak value dictionary is used to short-circuit creation so
|
||||
that multiple references to the same (object, function) pair
|
||||
produce the same BoundMethodWeakref instance.
|
||||
"""
|
||||
|
||||
_all_instances = weakref.WeakValueDictionary()
|
||||
|
||||
def __new__(cls, target, on_delete=None, *arguments, **named):
|
||||
"""Create new instance or return current instance.
|
||||
|
||||
Basically this method of construction allows us to
|
||||
short-circuit creation of references to already- referenced
|
||||
instance methods. The key corresponding to the target is
|
||||
calculated, and if there is already an existing reference,
|
||||
that is returned, with its deletion_methods attribute updated.
|
||||
Otherwise the new instance is created and registered in the
|
||||
table of already-referenced methods.
|
||||
"""
|
||||
key = cls.calculate_key(target)
|
||||
current = cls._all_instances.get(key)
|
||||
if current is not None:
|
||||
current.deletion_methods.append(on_delete)
|
||||
return current
|
||||
else:
|
||||
base = super(BoundMethodWeakref, cls).__new__(cls)
|
||||
cls._all_instances[key] = base
|
||||
base.__init__(target, on_delete, *arguments, **named)
|
||||
return base
|
||||
|
||||
def __init__(self, target, on_delete=None):
|
||||
"""Return a weak-reference-like instance for a bound method.
|
||||
|
||||
- ``target``: The instance-method target for the weak reference,
|
||||
must have im_self and im_func attributes and be
|
||||
reconstructable via the following, which is true of built-in
|
||||
instance methods::
|
||||
|
||||
target.im_func.__get__( target.im_self )
|
||||
|
||||
- ``on_delete``: Optional callback which will be called when
|
||||
this weak reference ceases to be valid (i.e. either the
|
||||
object or the function is garbage collected). Should take a
|
||||
single argument, which will be passed a pointer to this
|
||||
object.
|
||||
"""
|
||||
def remove(weak, self=self):
|
||||
"""Set self.isDead to True when method or instance is destroyed."""
|
||||
methods = self.deletion_methods[:]
|
||||
del self.deletion_methods[:]
|
||||
try:
|
||||
del self.__class__._all_instances[self.key]
|
||||
except KeyError:
|
||||
pass
|
||||
for function in methods:
|
||||
try:
|
||||
if callable(function):
|
||||
function(self)
|
||||
except Exception:
|
||||
try:
|
||||
traceback.print_exc()
|
||||
except AttributeError:
|
||||
e = sys.exc_info()[1]
|
||||
print ('Exception during saferef %s '
|
||||
'cleanup function %s: %s' % (self, function, e))
|
||||
self.deletion_methods = [on_delete]
|
||||
self.key = self.calculate_key(target)
|
||||
im_self = get_self(target)
|
||||
im_func = get_func(target)
|
||||
self.weak_self = weakref.ref(im_self, remove)
|
||||
self.weak_func = weakref.ref(im_func, remove)
|
||||
self.self_name = str(im_self)
|
||||
self.func_name = str(im_func.__name__)
|
||||
|
||||
def calculate_key(cls, target):
|
||||
"""Calculate the reference key for this reference.
|
||||
|
||||
Currently this is a two-tuple of the id()'s of the target
|
||||
object and the target function respectively.
|
||||
"""
|
||||
return (id(get_self(target)), id(get_func(target)))
|
||||
calculate_key = classmethod(calculate_key)
|
||||
|
||||
def __str__(self):
|
||||
"""Give a friendly representation of the object."""
|
||||
return "%s(%s.%s)" % (
|
||||
self.__class__.__name__,
|
||||
self.self_name,
|
||||
self.func_name,
|
||||
)
|
||||
|
||||
__repr__ = __str__
|
||||
|
||||
def __nonzero__(self):
|
||||
"""Whether we are still a valid reference."""
|
||||
return self() is not None
|
||||
|
||||
def __cmp__(self, other):
|
||||
"""Compare with another reference."""
|
||||
if not isinstance(other, self.__class__):
|
||||
return cmp(self.__class__, type(other))
|
||||
return cmp(self.key, other.key)
|
||||
|
||||
def __call__(self):
|
||||
"""Return a strong reference to the bound method.
|
||||
|
||||
If the target cannot be retrieved, then will return None,
|
||||
otherwise returns a bound instance method for our object and
|
||||
function.
|
||||
|
||||
Note: You may call this method any number of times, as it does
|
||||
not invalidate the reference.
|
||||
"""
|
||||
target = self.weak_self()
|
||||
if target is not None:
|
||||
function = self.weak_func()
|
||||
if function is not None:
|
||||
return function.__get__(target)
|
||||
return None
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user