Source code for cgl.core.path.query

from __future__ import annotations


[docs] def find_letter_in_drives(letter): """ The function searches for a single letter in the available drives. """ for key in get_drives(): if key.startswith(letter): return letter return None
[docs] def get_drives() -> dict: """ The function retrieves a dictionary of the drives on the computer and their available space. Returns: a dictionary containing the drives on the computer and their available space. """ import psutil drives = {} partitions = psutil.disk_partitions(all=True) for partition in partitions: if partition.fstype: size_in_gb = psutil.disk_usage(partition.mountpoint).free / (1024.0**3) drives[partition.device] = size_in_gb return drives