Package: titanarchive
TitanArchiveAn easy to use multiplatform archive extraction wrapper library for7-ZipFeaturesEasy API for C and Python. Greatly simplifies the complexity of using7-ZipMultiplatform. Supports Linux and WindowsVery fast. Written in modern C++Automatically discovers and determines archive typeSupports most archive formats: 7z, XZ, BZIP2, GZIP, TAR, ZIP, WIM, AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR and ZUsagePythonOpen archive on disk:fromtitanarchiveimportTitanArchivewithTitanArchive('test.zip')asta:# Do actionsOpen archive from memory buffer:fromtitanarchiveimportTitanArchivedata=open('test.zip','rb').read()withTitanArchive(data)asta:# Do actionsOpen archive from file descriptor:importosfromtitanarchiveimportTitanArchivefd=os.open('test.zip',os.O_RDONLY|(os.O_BINARYifos.name=='nt'else0))withTitanArchive(fd)asta:# Do actionsShow supported archive formats:importtitanarchiveprint(titanarchive.GlobalGetSupportedArchiveFormats())['APFS', 'APM', 'Ar', 'Arj', 'Base64', 'bzip2', 'Compound', 'Cpio', 'CramFS', 'Dmg', 'ELF', 'Ext', 'FAT', 'FLV', 'gzip', 'GPT', 'HFS', 'IHex', 'LP', 'Lzh', 'lzma', 'lzma86', 'MachO', 'MBR', 'MsLZ', 'Mub', 'NTFS', 'PE', 'COFF', 'TE', 'Ppmd', 'QCOW', 'Rpm', 'Sparse', 'Split', 'SquashFS', 'SWFc', 'SWF', 'UEFIc', 'UEFIf', 'VDI', 'VHD', 'VHDX', 'VMDK', 'Xar', 'xz', 'Z', '7z', 'Cab', 'Chm', 'Hxs', 'Iso', 'Nsis', 'Rar', 'Rar5', 'tar', 'Udf', 'wim', 'zip']Discover archive format:fromtitanarchiveimportTitanArchivewithTitanArchive('unknown.dat')asta:print('Format:{}'.format(ta.GetArchiveFormat()))Format: zipPrint all files and directories in archive (Method 1, by path):fromtitanarchiveimportTitanArchiveimportosdefprint_files(ta,path):foriteminta.ListDirectory(path):full_path=os.path.join(path,item.Path)ifitem.IsDir:print_files(ta,full_path)print('Item:{}'.format(full_path))withTitanArchive('test.zip')asta:print_files(ta,'')Item: dir1\another_file.txtItem: dir1\dir2\another_file.txtItem: dir1\dir2\dir3\file.txtItem: dir1\dir2\dir3Item: dir1\dir2\empty_directoryItem: dir1\dir2\file.txtItem: dir1\dir2Item: dir1\empty_directoryItem: dir1Item: empty_directoryItem: file_at_root.txtPrint all files and directories in archive (Method 2, by index):fromtitanarchiveimportTitanArchivewithTitanArchive('test.zip')asta:try:index=0whileTrue:item=ta.GetArchiveItemPropertiesByIndex(index)print('Item:{}'.format(item.Path))index+=1excepttitanarchive.TitanArchiveException:passItem: dir1Item: dir1\another_file.txtItem: dir1\dir2Item: dir1\dir2\another_file.txtItem: dir1\dir2\dir3Item: dir1\dir2\dir3\file.txtItem: dir1\dir2\empty_directoryItem: dir1\dir2\file.txtItem: dir1\empty_directoryItem: empty_directoryItem: file_at_root.txtExtract file to memory (Method 1, by path):fromtitanarchiveimportTitanArchivewithTitanArchive('test.zip')asta:data=ta.ExtractArchiveItemToBufferByPath('dir1\\another_file.txt')print(data.read())b'Test Data 123'Extract file to memory (Method 2, by index):fromtitanarchiveimportTitanArchivewithTitanArchive('test.zip')asta:properties=ta.GetArchiveItemPropertiesByPath('dir1\\another_file.txt')data=ta.ExtractArchiveItemToBufferByIndex(properties.Index)print(data.read())b'Test Data 123'