Skip to content

Commit e9fd307

Browse files
authored
Merge branch 'master' into switch-to-using-github-auto-generated-releases
2 parents bd346a0 + 1aedfb0 commit e9fd307

File tree

14 files changed

+240
-44
lines changed

14 files changed

+240
-44
lines changed

.github/workflows/tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths-ignore:
7+
- 'docs/**'
8+
- '*.rst'
9+
pull_request:
10+
paths-ignore:
11+
- 'docs/**'
12+
- '*.rst'
13+
jobs:
14+
tests:
15+
name: ${{ matrix.name }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- {name: Linux, python: '3.12', os: ubuntu-latest, tox: py312}
22+
- {name: Windows, python: '3.12', os: windows-latest, tox: py312}
23+
- {name: Mac, python: '3.12', os: macos-latest, tox: py312}
24+
- {name: '3.11', python: '3.11', os: ubuntu-latest, tox: py311}
25+
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
26+
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
27+
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
28+
- {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
29+
- {name: '3.6', python: '3.6', os: ubuntu-20.04, tox: py36} # ubuntu-latest doesn't support 3.6
30+
- {name: Style, python: '3.10', os: ubuntu-latest, tox: stylecheck}
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-python@v4
34+
with:
35+
python-version: ${{ matrix.python }}
36+
- name: update pip
37+
run: |
38+
pip install -U setuptools wheel
39+
python -m pip install -U pip
40+
- run: pip install tox
41+
- run: tox -e ${{ matrix.tox }}

.gitignore

Lines changed: 158 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,160 @@
1-
*.egg-info
2-
*.pyc
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
311
build/
12+
develop-eggs/
413
dist/
5-
docs/_build
6-
.tox
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
#.idea/

.travis.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Flask Debug-toolbar
44
This is a port of the excellent `django-debug-toolbar <https://github.com/jazzband/django-debug-toolbar>`_
55
for Flask applications.
66

7-
.. image:: https://travis-ci.org/flask-debugtoolbar/flask-debugtoolbar.png?branch=master
8-
:target: https://travis-ci.org/flask-debugtoolbar/flask-debugtoolbar
7+
.. image:: https://github.com/pallets-eco/flask-debugtoolbar/actions/workflows/tests.yml/badge.svg
8+
:target: https://github.com/pallets-eco/flask-debugtoolbar/actions
99

1010

1111
Installation

example/app.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ class ExampleModel(db.Model):
2828
value = db.Column(db.String(100), primary_key=True)
2929

3030

31-
@app.before_first_request
32-
def setup():
33-
db.create_all()
34-
35-
3631
@app.route('/')
3732
def index():
3833
app.logger.info("Hello there")
@@ -45,3 +40,7 @@ def redirect_example():
4540
response = redirect(url_for('index'))
4641
response.set_cookie('test_cookie', '1')
4742
return response
43+
44+
45+
with app.app_context():
46+
db.create_all()

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
'Blinker',
99
'itsdangerous',
1010
'werkzeug',
11+
'MarkupSafe',
1112
],
1213
)

src/flask_debugtoolbar/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import urllib.parse
23
import warnings
34

45
import flask
@@ -14,7 +15,6 @@
1415

1516
from jinja2 import __version__ as __jinja_version__
1617
from jinja2 import Environment, PackageLoader
17-
from werkzeug.urls import url_quote_plus
1818

1919
from flask_debugtoolbar.compat import iteritems
2020
from flask_debugtoolbar.toolbar import DebugToolbar
@@ -76,7 +76,7 @@ def __init__(self, app=None):
7676
autoescape=True,
7777
extensions=jinja_extensions,
7878
loader=PackageLoader(__name__, 'templates'))
79-
self.jinja_env.filters['urlencode'] = url_quote_plus
79+
self.jinja_env.filters['urlencode'] = urllib.parse.quote_plus
8080
self.jinja_env.filters['printable'] = _printable
8181
self.jinja_env.globals['url_for'] = url_for
8282

@@ -230,10 +230,11 @@ def process_response(self, response):
230230
response.headers['content-type'].startswith('text/html')):
231231
return response
232232

233-
if 'gzip' in response.headers.get('Content-Encoding', ''):
234-
response_html = gzip_decompress(response.data).decode(response.charset)
233+
content_encoding = response.headers.get('Content-Encoding')
234+
if content_encoding and 'gzip' in content_encoding:
235+
response_html = gzip_decompress(response.data).decode()
235236
else:
236-
response_html = response.data.decode(response.charset)
237+
response_html = response.get_data(as_text=True)
237238

238239
no_case = response_html.lower()
239240
body_end = no_case.rfind('</body>')
@@ -257,8 +258,8 @@ def process_response(self, response):
257258
toolbar_html = toolbar.render_toolbar()
258259

259260
content = ''.join((before, toolbar_html, after))
260-
content = content.encode(response.charset)
261-
if 'gzip' in response.headers.get('Content-Encoding', ''):
261+
content = content.encode('utf-8')
262+
if content_encoding and 'gzip' in content_encoding:
262263
content = gzip_compress(content)
263264
response.response = [content]
264265
response.content_length = len(content)

src/flask_debugtoolbar/panels/profiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ def process_response(self, request, response):
9494
def title(self):
9595
if not self.is_active:
9696
return "Profiler not active"
97-
return 'View: %.2fms' % (float(self.stats.total_tt)*1000,)
97+
return 'View: %.2fms' % (float(self.stats.total_tt) * 1000,)
9898

9999
def nav_title(self):
100100
return 'Profiler'
101101

102102
def nav_subtitle(self):
103103
if not self.is_active:
104104
return "in-active"
105-
return 'View: %.2fms' % (float(self.stats.total_tt)*1000,)
105+
return 'View: %.2fms' % (float(self.stats.total_tt) * 1000,)
106106

107107
def url(self):
108108
return ''

src/flask_debugtoolbar/panels/sqlalchemy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def extension_used():
6262

6363

6464
def recording_enabled():
65-
return (current_app.debug
66-
or current_app.config.get('SQLALCHEMY_RECORD_QUERIES'))
65+
return (current_app.debug or current_app.config.get('SQLALCHEMY_RECORD_QUERIES'))
6766

6867

6968
def is_available():

src/flask_debugtoolbar/panels/timer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def url(self):
5252
return ''
5353

5454
def _elapsed_ru(self, name):
55-
return (getattr(self._end_rusage, name)
56-
- getattr(self._start_rusage, name))
55+
return (getattr(self._end_rusage, name) - getattr(self._start_rusage, name))
5756

5857
def content(self):
5958

0 commit comments

Comments
 (0)