Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def delete_imagepdf(self, item, abby_filegz):
head, abby_file = os.path.split(abby_filegz)
pdffile = re.sub('_abbyy.gz$', '.pdf', abby_file)
itemobj = internetarchive.get_item(item)
fileobj = internetarchive.File(itemobj, pdffile)
if fileobj and fileobj.source == 'derivative' and \
fileobj.format == 'Image Container PDF':
fileobj.delete(access_key = self.access_key, headers= self.headers,\
secret_key = self.secret_key)
self.logger.warn('Old image pdf exists in %s. Deleted it', item)