Skip to content

Commit 6e9ce48

Browse files
authored
Refactor is_project_func method for Windows compatibility (#1857)
1 parent fb16de1 commit 6e9ce48

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

debug_toolbar/panels/profiling.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ def is_project_func(self):
4242
"""
4343
if hasattr(settings, "BASE_DIR"):
4444
file_name, _, _ = self.func
45-
return (
46-
str(settings.BASE_DIR) in file_name
47-
and "/site-packages/" not in file_name
48-
and "/dist-packages/" not in file_name
45+
base_dir = str(settings.BASE_DIR)
46+
47+
file_name = os.path.normpath(file_name)
48+
base_dir = os.path.normpath(base_dir)
49+
50+
return file_name.startswith(base_dir) and not any(
51+
directory in file_name.split(os.path.sep)
52+
for directory in ["site-packages", "dist-packages"]
4953
)
5054
return None
5155

0 commit comments

Comments
 (0)