From 658e6c0eeec34cd6b64754f2e28d64e9f73c4019 Mon Sep 17 00:00:00 2001 From: Prafful Sharma Date: Sat, 18 Nov 2023 00:02:23 +0530 Subject: [PATCH 1/2] Refactor is_project_func method for Windows compatibility --- debug_toolbar/panels/profiling.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py index 9d10229ad..876e589a8 100644 --- a/debug_toolbar/panels/profiling.py +++ b/debug_toolbar/panels/profiling.py @@ -42,10 +42,17 @@ def is_project_func(self): """ if hasattr(settings, "BASE_DIR"): file_name, _, _ = self.func + base_dir = str(settings.BASE_DIR) + + file_name = os.path.normpath(file_name) + base_dir = os.path.normpath(base_dir) + return ( - str(settings.BASE_DIR) in file_name - and "/site-packages/" not in file_name - and "/dist-packages/" not in file_name + file_name.startswith(base_dir) + and not any( + directory in file_name.split(os.path.sep) + for directory in ["site-packages", "dist-packages"] + ) ) return None From 69f34937f836924ebbb4014d4bebb0ef89cf58bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Nov 2023 18:42:31 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- debug_toolbar/panels/profiling.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py index 876e589a8..2b7742400 100644 --- a/debug_toolbar/panels/profiling.py +++ b/debug_toolbar/panels/profiling.py @@ -47,12 +47,9 @@ def is_project_func(self): file_name = os.path.normpath(file_name) base_dir = os.path.normpath(base_dir) - return ( - file_name.startswith(base_dir) - and not any( - directory in file_name.split(os.path.sep) - for directory in ["site-packages", "dist-packages"] - ) + return file_name.startswith(base_dir) and not any( + directory in file_name.split(os.path.sep) + for directory in ["site-packages", "dist-packages"] ) return None