'Remove a single swap or base file if it is old enough.'

def _remove_old_enough_file(self, base_file, maxage, remove_lock=True):

    (exists, age) = self._get_age_of_file(base_file)
    if (not exists):
        return
    lock_file = os.path.split(base_file)[(-1)]
    @utils.synchronized(lock_file, external=True, lock_path=self.lock_path)
    def _inner_remove_old_enough_file():
        (exists, age) = self._get_age_of_file(base_file)
        if ((not exists) or (age < maxage)):
            return
        LOG.info('Removing    base    or    swap    file:    %s', base_file)
        try:
            os.remove(base_file)
            signature = get_info_filename(base_file)
            if os.path.exists(signature):
                os.remove(signature)
        except OSError as e:
            LOG.error('Failed    to    remove    %(base_file)s,    error    was    %(error)s', {'base_file': base_file, 'error': e})
    if (age < maxage):
        LOG.info('Base    or    swap    file    too    young    to    remove:    %s', base_file)
    else:
        _inner_remove_old_enough_file()
        if remove_lock:
            try:
                lockutils.remove_external_lock_file(lock_file, lock_file_prefix='nova-', lock_path=self.lock_path)
            except OSError as e:
                LOG.debug('Failed    to    remove    %(lock_file)s,    error    was    %(error)s', {'lock_file': lock_file, 'error': e})
