1
0
espelhamento de https://github.com/arsenetar/send2trash.git sincronizado 2025-09-11 18:08:16 +00:00

Support for any iterable type as input data

Esse commit está contido em:
Andrey Efremov 2024-01-11 14:25:22 +07:00
commit ed039dc892
2 arquivos alterados com 10 adições e 1 exclusões

Ver arquivo

@ -18,3 +18,8 @@ else:
text_type = unicode # noqa: F821
binary_type = str
environb = os.environ
try:
from collections.abc import Iterable as iterable_type
except ImportError:
from collections import Iterable as iterable_type

Ver arquivo

@ -5,9 +5,13 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from send2trash.compat import text_type, binary_type, iterable_type
def preprocess_paths(paths):
if not isinstance(paths, list):
if isinstance(paths, iterable_type) and not isinstance(paths, (text_type, binary_type)):
paths = list(paths)
elif not isinstance(paths, list):
paths = [paths]
# Convert items such as pathlib paths to strings
paths = [path.__fspath__() if hasattr(path, "__fspath__") else path for path in paths]