Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def device_id(self):
"""
Return a unique and persistent identifier for the device.
This is the basename (last path component) of the symlink in
`/dev/disk/by-id/`.
"""
if self.is_block:
for filename in self._P.Block.Symlinks:
parts = decode_ay(filename).split('/')
if parts[-2] == 'by-id':
return parts[-1]
elif self.is_drive:
return self._assocdrive._P.Drive.Id
return ''
def mount_paths(self):
"""Return list of active mount paths."""
return list(map(decode_ay, self._P.Filesystem.MountPoints or ()))
def device_presentation(self):
"""The device file path to present to the user."""
return decode_ay(self._P.Block.PreferredDevice)
def symlinks(self):
"""Known symlinks of the block device."""
if not self._P.Block.Symlinks:
return []
return [decode_ay(path) for path in self._P.Block.Symlinks]
def device_file(self):
"""The filesystem path of the device block file."""
return decode_ay(self._P.Block.Device)
def loop_file(self):
"""Get the file backing the loop device."""
return decode_ay(self._P.Loop.BackingFile)