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.

24 lines
703 B

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