Delete copy of resource in filename on local system.

        Will only actually do the deletion if allow_deletion is True. Regardless
        of whether the deletion occurs, self.last_timestamp will be updated
        if the resource.timestamp is later than the current value.

        Returns the number of files actually deleted (0 or 1).

def delete_resource(self, resource, filename, allow_deletion=False):
        """Delete copy of resource in filename on local system.

        Will only actually do the deletion if allow_deletion is True. Regardless
        of whether the deletion occurs, self.last_timestamp will be updated
        if the resource.timestamp is later than the current value.

        Returns the number of files actually deleted (0 or 1).
        """
        num_deleted = 0
        uri = resource.uri
        if (resource.timestamp is not None and
                resource.timestamp > self.last_timestamp):
            self.last_timestamp = resource.timestamp
        if (allow_deletion):
            if (self.dryrun):
                self.logger.info(
                    "dryrun: would delete %s -> %s" %
                    (uri, filename))
            else:
                try:
                    os.unlink(filename)
                    num_deleted += 1
                    self.logger.info("deleted: %s -> %s" % (uri, filename))
                    self.log_event(
                        Resource(
                            resource=resource,
                            change="deleted"))
                except OSError as e:
                    msg = "Failed to DELETE %s -> %s : %s" % (
                        uri, filename, str(e))
                    # if (self.ignore_failures):
                    self.logger.warning(msg)
                    #    return
                    # else:
                    #    raise ClientFatalError(msg)
        else:
            self.logger.info(
                "nodelete: would delete %s (--delete to enable)" %
                uri)
        return(num_deleted)