def _validate_device(device):
 if os.path.exists(device):
  dev = os.stat(device).st_mode
  if stat.S_ISBLK(dev):
   return
 raise CommandExecutionError('Invalid device passed to partition module.')

def _validate_device ( device ) : if os . path . exists ( device ) : dev = os . stat ( device ) . st_mode if stat . S_ISBLK ( dev ) : return raise CommandExecutionError ( 'Invalid device passed to partition module.' )
ensure the device name supplied is valid in a manner similar to the exists function .