parameters: (device, options)
docstring: Wipes data from device, keeping only the adb_keys for authorization.
  
    After wiping data on a device that has been authorized, adb can still
    communicate with the device, but after reboot the device will need to be
    re-authorized because the adb keys file is stored in /data/misc/adb/.
    Thus, adb_keys file is rewritten so the device does not need to be
    re-authorized.
  
    Arguments:
      device: the device to wipe
docstring_summary: Wipes data from device, keeping only the adb_keys for authorization.
docstring_tokens: Wipes data from device keeping only the adb_keys for authorization .
function: def WipeDevice(device, options):
    """Wipes data from device, keeping only the adb_keys for authorization.
  
    After wiping data on a device that has been authorized, adb can still
    communicate with the device, but after reboot the device will need to be
    re-authorized because the adb keys file is stored in /data/misc/adb/.
    Thus, adb_keys file is rewritten so the device does not need to be
    re-authorized.
  
    Arguments:
      device: the device to wipe
    """
    if options.skip_wipe:
      return
  
    try:
      device.EnableRoot()
      device_authorized = device.FileExists(constants.ADB_KEYS_FILE)
      if device_authorized:
        adb_keys = device.ReadFile(constants.ADB_KEYS_FILE,
                                   as_root=True).splitlines()
      device.RunShellCommand(['wipe', 'data'],
                             as_root=True, check_return=True)
      device.adb.WaitForDevice()
  
      if device_authorized:
        adb_keys_set = set(adb_keys)
        for adb_key_file in options.adb_key_files or []:
          try:
            with open(adb_key_file, 'r') as f:
              adb_public_keys = f.readlines()
            adb_keys_set.update(adb_public_keys)
          except IOError:
            logging.warning('Unable to find adb keys file %s.', adb_key_file)
        _WriteAdbKeysFile(device, '\n'.join(adb_keys_set))
    except device_errors.CommandFailedError:
      logging.exception('Possible failure while wiping the device. '
                        'Attempting to continue.')
function_tokens: def WipeDevice ( device , options ) : if options . skip_wipe : return try : device . EnableRoot ( ) device_authorized = device . FileExists ( constants . ADB_KEYS_FILE ) if device_authorized : adb_keys = device . ReadFile ( constants . ADB_KEYS_FILE , as_root = True ) . splitlines ( ) device . RunShellCommand ( [ 'wipe' , 'data' ] , as_root = True , check_return = True ) device . adb . WaitForDevice ( ) if device_authorized : adb_keys_set = set ( adb_keys ) for adb_key_file in options . adb_key_files or [ ] : try : with open ( adb_key_file , 'r' ) as f : adb_public_keys = f . readlines ( ) adb_keys_set . update ( adb_public_keys ) except IOError : logging . warning ( 'Unable to find adb keys file %s.' , adb_key_file ) _WriteAdbKeysFile ( device , '\n' . join ( adb_keys_set ) ) except device_errors . CommandFailedError : logging . exception ( 'Possible failure while wiping the device. ' 'Attempting to continue.' )