You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
787 B

  1. from ctypes import windll
  2. import os
  3. #https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
  4. #u=RichieHindle
  5. def get_drives():
  6. uppercase = map(chr,range(ord('A'),ord('A')+26))
  7. drives = []
  8. bitmask = windll.kernel32.GetLogicalDrives()
  9. for letter in uppercase:
  10. if bitmask & 1:
  11. drives.append(f'{letter}:\\')
  12. bitmask >>= 1
  13. return drives
  14. def no_parents(paths):
  15. paths = sorted(paths,key=len)
  16. ret = []
  17. paths
  18. while len(paths) > 0:
  19. el1 = paths[0]
  20. ret.append(el1)
  21. old_paths = paths[1:]
  22. paths = []
  23. for path in old_paths:
  24. if not path.startswith(el1):
  25. paths.append(path)
  26. return ret