-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
692a728
commit ef70986
Showing
3 changed files
with
25 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import os | ||
from collections.abc import Iterable | ||
from pathlib import Path | ||
|
||
|
||
def convert_to_str_paths(filenames): | ||
"""Converts filenames to string paths, handling both string and pathlib.Path objects and | ||
iterables of such objects. | ||
Args: | ||
filenames (str, Path, or Iterable[str | Path]): A single filepath or an iterable of | ||
filepaths to convert to str object(s). | ||
Returns: | ||
list[str]: A list of filepaths as strings. | ||
""" | ||
|
||
if isinstance(filenames, Iterable) and not isinstance(filenames, (str, Path)): | ||
return [os.fspath(fn) for fn in filenames] | ||
|
||
return [os.fspath(filenames)] |