

def _recover_checkpoint(self, cp_dir):
    'Recover a specific checkpoint.\n\n        Recover a specific checkpoint provided by cp_dir\n        Note: this function does not reload augeas.\n\n        :param str cp_dir: checkpoint directory file path\n\n        :raises errors.ReverterError: If unable to recover checkpoint\n\n        '
    if os.path.isfile(os.path.join(cp_dir, 'COMMANDS')):
        self._run_undo_commands(os.path.join(cp_dir, 'COMMANDS'))
    if os.path.isfile(os.path.join(cp_dir, 'FILEPATHS')):
        try:
            with open(os.path.join(cp_dir, 'FILEPATHS')) as paths_fd:
                filepaths = paths_fd.read().splitlines()
                for (idx, path) in enumerate(filepaths):
                    shutil.copy2(os.path.join(cp_dir, ((os.path.basename(path) + '_') + str(self))), path)
        except (IOError, OSError):
            logger.error('Unable to recover files from %s', cp_dir)
            raise errors.ReverterError(('Unable to recover files from %s' % cp_dir))
    self._remove_contained_files(os.path.join(cp_dir, 'NEW_FILES'))
    try:
        shutil.rmtree(cp_dir)
    except OSError:
        logger.error('Unable to remove directory: %s', cp_dir)
        raise errors.ReverterError(('Unable to remove directory: %s' % cp_dir))

dataset/ETHPy150Open letsencrypt/letsencrypt/certbot/reverter.py Reverter._recover_checkpoint/VarMisuse@150/296 `idx`->`self`