MCPcopy
hub / github.com/corpnewt/gibMacOS / get_identifier

Method get_identifier

Scripts/disk.py:215–236  ·  view source on GitHub ↗
(self, disk)

Source from the content-addressed store, hash-verified

213 return False
214
215 def get_identifier(self, disk):
216 # Should be able to take a mount point, disk name, or disk identifier,
217 # and return the disk's identifier
218 # Iterate!!
219 if not disk or not len(self._get_str(disk)):
220 return None
221 disk = self._get_str(disk).lower()
222 if disk.startswith("/dev/r"):
223 disk = disk[len("/dev/r"):]
224 elif disk.startswith("/dev/"):
225 disk = disk[len("/dev/"):]
226 if disk in self.disks.get("AllDisks", []):
227 return disk
228 for d in self.disks.get("AllDisksAndPartitions", []):
229 for a in d.get("APFSVolumes", []):
230 if disk in [ self._get_str(a.get(x, "")).lower() for x in ["DeviceIdentifier", "VolumeName", "VolumeUUID", "DiskUUID", "MountPoint"] ]:
231 return a.get("DeviceIdentifier", None)
232 for a in d.get("Partitions", []):
233 if disk in [ self._get_str(a.get(x, "")).lower() for x in ["DeviceIdentifier", "VolumeName", "VolumeUUID", "DiskUUID", "MountPoint"] ]:
234 return a.get("DeviceIdentifier", None)
235 # At this point, we didn't find it
236 return None
237
238 def get_top_identifier(self, disk):
239 disk_id = self.get_identifier(disk)

Callers 15

get_disk_infoMethod · 0.95
get_disk_fsMethod · 0.95
get_disk_fs_typeMethod · 0.95
is_apfsMethod · 0.95
is_apfs_containerMethod · 0.95
is_cs_containerMethod · 0.95
is_core_storageMethod · 0.95
get_top_identifierMethod · 0.95
get_physical_storeMethod · 0.95
get_core_storage_pvMethod · 0.95
get_parentMethod · 0.95
get_efiMethod · 0.95

Calls 1

_get_strMethod · 0.95

Tested by

no test coverage detected