mirror of
https://github.com/arsenetar/send2trash.git
synced 2026-03-15 12:01:39 +00:00
Add ability to handle pathlib paths
- Handle pathlib paths across all implementations, plat_other already did - Move preprocessing code to common location
This commit is contained in:
16
send2trash/util.py
Normal file
16
send2trash/util.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# encoding: utf-8
|
||||
# Copyright 2017 Virgil Dupras
|
||||
|
||||
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
|
||||
def preprocess_paths(paths):
|
||||
if 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
|
||||
]
|
||||
return paths
|
||||
Reference in New Issue
Block a user