flask-debugtoolbar-0.15.1/ 0000775 0001750 0001750 00000000000 14613236757 015227 5 ustar kalyani kalyani flask-debugtoolbar-0.15.1/.gitignore 0000664 0001750 0001750 00000006006 14613236757 017221 0 ustar kalyani kalyani # Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
flask-debugtoolbar-0.15.1/example/ 0000775 0001750 0001750 00000000000 14613236757 016662 5 ustar kalyani kalyani flask-debugtoolbar-0.15.1/example/templates/ 0000775 0001750 0001750 00000000000 14613236757 020660 5 ustar kalyani kalyani flask-debugtoolbar-0.15.1/example/templates/index.html 0000664 0001750 0001750 00000000327 14613236757 022657 0 ustar kalyani kalyani
Flask-debug-toolbar
Flask-debug-toolbar
Redirect example
flask-debugtoolbar-0.15.1/example/app.py 0000664 0001750 0001750 00000002506 14613236757 020017 0 ustar kalyani kalyani # Run using: `FLASK_DEBUG=True flask run`
from flask import Flask, render_template, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
from flask_debugtoolbar import DebugToolbarExtension
app = Flask(__name__)
app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True
#app.config['DEBUG_TB_PANELS'] = (
# 'flask_debugtoolbar.panels.headers.HeaderDebugPanel',
# 'flask_debugtoolbar.panels.logger.LoggingPanel',
# 'flask_debugtoolbar.panels.timer.TimerDebugPanel',
#)
#app.config['DEBUG_TB_HOSTS'] = ('127.0.0.1', '::1' )
app.config['SECRET_KEY'] = 'asd'
app.config['SQLALCHEMY_RECORD_QUERIES'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
# This is no longer needed for Flask-SQLAlchemy 3.0+, if you're using 2.X you'll want to define this:
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
toolbar = DebugToolbarExtension(app)
class ExampleModel(db.Model):
__tablename__ = 'examples'
value = db.Column(db.String(100), primary_key=True)
@app.route('/')
def index():
app.logger.info("Hello there")
ExampleModel.query.get(1)
return render_template('index.html')
@app.route('/redirect')
def redirect_example():
response = redirect(url_for('index'))
response.set_cookie('test_cookie', '1')
return response
with app.app_context():
db.create_all()
flask-debugtoolbar-0.15.1/test/ 0000775 0001750 0001750 00000000000 14613236757 016206 5 ustar kalyani kalyani flask-debugtoolbar-0.15.1/test/conftest.py 0000664 0001750 0001750 00000000210 14613236757 020376 0 ustar kalyani kalyani import pytest
@pytest.fixture(autouse=True)
def mock_env_development(monkeypatch):
monkeypatch.setenv("FLASK_ENV", "development")
flask-debugtoolbar-0.15.1/test/test_utils.py 0000664 0001750 0001750 00000007507 14613236757 020770 0 ustar kalyani kalyani import ntpath
import posixpath
from markupsafe import Markup
import pytest
from flask_debugtoolbar.utils import (_relative_paths, _shortest_relative_path,
format_sql, decode_text, HAVE_PYGMENTS)
@pytest.mark.parametrize('value,paths,expected,path_module', [
# should yield relative path to the parent directory
('/foo/bar', ['/foo'], ['bar'], posixpath),
('c:\\foo\\bar', ['c:\\foo'], ['bar'], ntpath),
# should not yield result if no path is a parent directory
('/foo/bar', ['/baz'], [], posixpath),
('c:\\foo\\bar', ['c:\\baz'], [], ntpath),
# should only yield relative paths for parent directories
('/foo/bar', ['/foo', '/baz'], ['bar'], posixpath),
('c:\\foo\\bar', ['c:\\foo', 'c:\\baz'], ['bar'], ntpath),
# should yield all results when multiple parents match
('/foo/bar/baz', ['/foo', '/foo/bar'], ['bar/baz', 'baz'], posixpath),
('c:\\foo\\bar\\baz', ['c:\\foo', 'c:\\foo\\bar'],
['bar\\baz', 'baz'], ntpath),
# should ignore case differences on windows
('c:\\Foo\\bar', ['c:\\foo'], ['bar'], ntpath),
# should preserve original case
('/Foo/Bar', ['/Foo'], ['Bar'], posixpath),
('c:\\Foo\\Bar', ['c:\\foo'], ['Bar'], ntpath),
])
def test_relative_paths(value, paths, expected, path_module):
assert list(_relative_paths(value, paths, path_module)) == expected
@pytest.mark.parametrize('value,paths,expected,path_module', [
# should yield relative path to the parent directory
('/foo/bar', ['/foo'], 'bar', posixpath),
('c:\\foo\\bar', ['c:\\foo'], 'bar', ntpath),
# should return the original value if no path is a parent directory
('/foo/bar', ['/baz'], '/foo/bar', posixpath),
('c:\\foo\\bar', ['c:\\baz'], 'c:\\foo\\bar', ntpath),
# should yield shortest result when multiple parents match
('/foo/bar/baz', ['/foo', '/foo/bar'], 'baz', posixpath),
('c:\\foo\\bar\\baz', ['c:\\foo', 'c:\\foo\\bar'], 'baz', ntpath),
])
def test_shortest_relative_path(value, paths, expected, path_module):
assert _shortest_relative_path(value, paths, path_module) == expected
def test_decode_text_unicode():
value = u'\uffff'
decoded = decode_text(value)
assert decoded == value
def test_decode_text_ascii():
value = 'abc'
assert decode_text(value.encode('ascii')) == value
def test_decode_text_non_ascii():
value = b'abc \xff xyz'
assert isinstance(value, bytes)
decoded = decode_text(value)
assert not isinstance(decoded, bytes)
assert decoded.startswith('abc')
assert decoded.endswith('xyz')
@pytest.fixture()
def no_pygments(monkeypatch):
monkeypatch.setattr('flask_debugtoolbar.utils.HAVE_PYGMENTS', False)
def test_format_sql_no_pygments(no_pygments):
sql = 'select 1'
assert format_sql(sql, {}) == sql
def test_format_sql_no_pygments_non_ascii(no_pygments):
sql = b"select '\xff'"
formatted = format_sql(sql, {})
assert formatted.startswith(u"select '")
def test_format_sql_no_pygments_escape_html(no_pygments):
sql = 'select x < 1'
formatted = format_sql(sql, {})
assert not isinstance(formatted, Markup)
assert Markup('%s') % formatted == 'select x < 1'
@pytest.mark.skipif(not HAVE_PYGMENTS,
reason='test requires the "Pygments" library')
def test_format_sql_pygments():
sql = 'select 1'
html = format_sql(sql, {})
assert isinstance(html, Markup)
assert html.startswith('