Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions debug_toolbar/panels/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from pprint import pformat

from django.utils.translation import gettext_lazy as _
from django.views.debug import get_default_exception_reporter_filter

from debug_toolbar.panels import Panel
from debug_toolbar.sanitize import force_str

get_safe_settings = get_default_exception_reporter_filter().get_safe_settings

Expand All @@ -27,7 +28,7 @@ def generate_stats(self, request, response):
self.record_stats(
{
"settings": {
key: force_str(value)
key: pformat(value)
for key, value in sorted(get_safe_settings().items())
}
}
Expand Down
37 changes: 13 additions & 24 deletions debug_toolbar/panels/sql/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import cache, lru_cache
from html import escape
from itertools import cycle

import sqlparse
from django.dispatch import receiver
Expand Down Expand Up @@ -136,27 +137,15 @@ def contrasting_color_generator():
and then vary subsequent bits systematically.
"""

def rgb_to_hex(rgb):
return "#{:02x}{:02x}{:02x}".format(*tuple(rgb))

triples = [
(1, 0, 0),
(0, 1, 0),
(0, 0, 1),
(1, 1, 0),
(0, 1, 1),
(1, 0, 1),
(1, 1, 1),
]
n = 1 << 7
so_far = [[0, 0, 0]]
while True:
if n == 0: # This happens after 2**24 colours; presumably, never
yield "#000000" # black
copy_so_far = list(so_far)
for triple in triples:
for previous in copy_so_far:
rgb = [n * triple[i] + previous[i] for i in range(3)]
so_far.append(rgb)
yield rgb_to_hex(rgb)
n >>= 1
return cycle(
[
"#0C375A",
"#21A0A0",
"#FFC300",
"#FF5733",
"#C70039",
"#900C3F",
"#581845",
"#F1C40F",
]
)
Loading
Loading