Skip to content

Commit

Permalink
some minor refactor in search_for_file in file_utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed May 3, 2024
1 parent 5db8874 commit 69e3a07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions dcicutils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ def search_for_file(file: str,
directory = str(directory)
if not (directory := directory.strip()):
continue
if os.path.isfile(directory):
if os.path.isfile(directory := os.path.normpath(directory)):
# Allow a file; assume its parent directory was intended.
if not (directory := os.path.dirname(directory)):
continue
location_pruned.append(directory)
if directory not in location_pruned:
location_pruned.append(directory)
location = location_pruned
for directory in location:
if os.path.exists(os.path.join(directory, file)):
Expand All @@ -59,8 +60,6 @@ def search_for_file(file: str,
files_found.append(file_found)
if recursive is True:
for directory in location:
if not directory:
continue
if not directory.endswith("/**") and not file.startswith("**/"):
path = f"{directory}/**/{file}"
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "8.8.4.1b18" # TODO: To become 8.8.5
version = "8.8.4.1b19" # TODO: To become 8.8.5
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
license = "MIT"
Expand Down

0 comments on commit 69e3a07

Please sign in to comment.