path.py 427 B

12345678910111213141516171819202122
  1. #
  2. # Copyright (C) 2016 Intel Corporation
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. import os
  7. import sys
  8. def findFile(file_name, directory):
  9. """
  10. Search for a file in directory and returns its complete path.
  11. """
  12. for r, d, f in os.walk(directory):
  13. if file_name in f:
  14. return os.path.join(r, file_name)
  15. return None
  16. def remove_safe(path):
  17. if os.path.exists(path):
  18. os.remove(path)