From 6d99340944a1d9b60ec8b6956276faf48c2bcd9c Mon Sep 17 00:00:00 2001 From: Glenn Snyder Date: Fri, 5 Mar 2021 12:27:41 -0500 Subject: [PATCH] Path.is_related_to is only in python 3.9 so changing to related_to method to be compatible with older python versions --- bd-splitter.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bd-splitter.py b/bd-splitter.py index 0e877cf..4ad2d2e 100644 --- a/bd-splitter.py +++ b/bd-splitter.py @@ -114,7 +114,17 @@ def in_exclude_list(abs_path): # TODO: Need to pop folders from the exclude list as we deal with them. How? if subdir not in scan_dirs and subdir not in exclude_folders: logging.debug(f"adding subdir {subdir} to list of directories to scan") - exclude_folders_under_subdir = [f for f in exclude_folders if f.is_relative_to(subdir)] + exclude_folders_under_subdir = list() + for f in exclude_folders: + try: + f.relative_to(subdir) + except ValueError: + logging.debug(f"folder {f} is not a sub-dir of {subdir}") + continue + else: + logging.debug(f"folder {f} is a sub-dir of {subdir} so will exclude it from detect scan of {subdir}") + exclude_folders_under_subdir.append(f) + # exclude_folders_under_subdir = [f for f in exclude_folders if f.is_relative_to(subdir)] logging.debug(f"excluding dirs {exclude_folders_under_subdir} from subdir {subdir} analysis") scan_dirs[subdir] = {"exclude_folders": exclude_folders_under_subdir} exclude_folders -= set(exclude_folders_under_subdir)