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.

27 lines
697 B

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