util.py 583 B

123456789101112131415161718
  1. # encoding: utf-8
  2. # Copyright 2017 Virgil Dupras
  3. # This software is licensed under the "BSD" License as described in the "LICENSE" file,
  4. # which should be included with this package. The terms are also available at
  5. # http://www.hardcoded.net/licenses/bsd_license
  6. import os
  7. import collections.abc
  8. def preprocess_paths(paths):
  9. if isinstance(paths, collections.abc.Iterable) and not isinstance(paths, (str, bytes)):
  10. paths = list(paths)
  11. else:
  12. paths = [paths]
  13. # Convert items such as pathlib paths to strings
  14. return [os.fspath(path) for path in paths]