def open_archive_entry(entry): """ Convenience function for opening archives from entries. Returns an archive.Archive object """ archive = None try: archive_path = entry.get('location', '') if not archive_path: log.error('Entry does not appear to represent a local file.') elif not os.path.exists(archive_path): log.error('File no longer exists: %s', entry['location']) else: archive = archiveutil.open_archive(archive_path) except archiveutil.BadArchive as error: fail_entry_with_error(entry, 'Bad archive: %s (%s)' % (archive_path, error)) except archiveutil.NeedFirstVolume: log.error('Not the first volume: %s', archive_path) except archiveutil.ArchiveError as error: fail_entry_with_error( entry, 'Failed to open Archive: %s (%s)' % (archive_path, error)) return archive
def open_archive_entry(entry): """ Convenience function for opening archives from entries. Returns an archive.Archive object """ archive = None try: archive_path = entry.get('location', '') if not archive_path: log.error('Entry does not appear to represent a local file.') elif not os.path.exists(archive_path): log.error('File no longer exists: %s', entry['location']) else: archive = archiveutil.open_archive(archive_path) except archiveutil.BadArchive as error: fail_entry_with_error(entry, 'Bad archive: %s (%s)' % (archive_path, error)) except archiveutil.NeedFirstVolume: log.error('Not the first volume: %s', archive_path) except archiveutil.ArchiveError as error: fail_entry_with_error(entry, 'Failed to open Archive: %s (%s)' % (archive_path, error)) return archive