Package: pydwarfs
PyDwarfsA wrapper of DwarFS command line utilities.DwarFS is stands forDeduplicating Warp-speed Advanced Read-only File System, it is a fast high compression read-only file system for Linux and Windows.See this project's homepage.Note: This project currently does not provide support for Windows version of DwarFS command line utility.Features / TODOMount/unmount a DwarFS image file to specified mountpoint (dwarfs/mount.dwarfs)Extract a DwarFS image file (dwarfsextract, initially implemented)Create a DwarFS image file (mkdwarfs)Check a DwarFS image file (dwarfsck)Performance test (dwarfsbench)InstallJust run the command:pip install pydwarfs.Or you can download and install the wheel file from release page manually.ExamplesThe following examples are for the more common uses of command line utilities.Mount/unmount a DwarFS image file to specified mountpointCheck if a path is a DwarFS mountpoint>>>frompydwarfs.dwarfsimportDwarFS>>>DwarFS.isDwarFSMountPoint(this_is_dwarfs_mnt)True>>>DwarFS.isDwarFSMountPoint('/path/to/non-mnt')False>>>DwarFS.isDwarFSMountPoint('/proc')# Obviously not a DwarFS mountpointFalse>>>List all of DwarFS mountpoint>>>DwarFS.listAllDwarFSMountPoints()[MountPoint(source='dwarfs', target=PosixPath('/path/to/dwarfs/image/mountpoint'), fstype='fuse.dwarfs', options=('rw', 'nosuid', 'nodev', 'relatime', 'user_id=1000', 'group_id=1000'), freq=0, passno=0), ...]>>>Create aDwarFSinstanceIn the default case,Dwarfs.init()will find the location ofdwarfscommand viashutil.which().>>>frompydwarfs.dwarfsimportDwarFS>>>dwarfs=Dwarfs.init()>>>dwarfs.executable'/usr/bin/dwarfs'>>>If the DwarFS command line utilities are not installed, you can specify a location ofdwarfscommand instead.>>>frompydwarfs.dwarfsimportDwarFS>>>dwarfs=Dwarfs.init('/path/to/valid/dwarfs')>>>dwarfs.executable'/path/to/valid/dwarfs'>>>A simple mount>>>dwarfs.mount('/path/to/source.dwarfs','/path/to/destination/directory')>>>To check if the mount was actually successful, exit the Python REPL and run the following command:$ > findmnt /path/to/destination/directory
TARGET                         SOURCE FSTYPE      OPTIONS
/path/to/destination/directory dwarfs fuse.dwarfs rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
$ >Mount with some specified optionsUse the dedicated attribute classDwarFSMountOptions:>>>frompydwarfs.dwarfsimportDwarFS,DwarFSMountOptions>>>dwarfs=Dwarfs.init()>>>options1=DwarFSMountOptions(cachefile='32M',readonly=True,debuglevel='debug')>>>dwarfs.mount('/path/to/source.1.dwarfs','/path/to/destination/directory.1',options)I 04:06:32.182380 [dwarfs_main.cpp:1328] dwarfs (v0.7.4, fuse version 35)D 04:06:32.182909 [filesystem_v2.cpp:482] found valid section indexD 04:06:32.182927 [filesystem_v2.cpp:493] section BLOCK @ 64 [16,669,939 bytes]...D 04:06:32.191025 [filesystem_v2.cpp:515] read 734 blocks and 175,158 bytes of metadataI 04:06:32.191041 [dwarfs_main.cpp:1144] file system initialized [8.624ms]>>>Or simply specify options by dict and **kwargs:>>>frompydwarfs.dwarfsimportDwarFS,DwarFSMountOptions>>>dwarfs=Dwarfs.init()>>>options2={'cachefile':'16M','readonly':True}>>>dwarfs.mount('/path/to/source.2.dwarfs','/path/to/destination/directory.2',options,debuglevel='debug')I 04:14:01.981335 [dwarfs_main.cpp:1328] dwarfs (v0.7.4, fuse version 35)D 04:14:01.983736 [filesystem_v2.cpp:482] found valid section indexD 04:14:01.983753 [filesystem_v2.cpp:493] section BLOCK @ 64 [67,097,028 bytes]...D 04:14:01.984644 [filesystem_v2.cpp:515] read 7 blocks and 2,755 bytes of metadataI 04:14:01.984656 [dwarfs_main.cpp:1144] file system initialized [3.27ms]>>>Unmount>>>dwarfs.unmount('/path/to/destination/directory')>>>Unmount by the methodumountinstead of the defaultfusermount:>>>dwarfs.unmount('/path/to/destination/directory.1',method='umount')>>>You can forcely unmount by add the argumentlazy_unmount=True:>>>dwarfs.unmount('/path/to/destination/directory.2',lazy_unmount=True)>>>Extract a DwarFS image fileA simple extraction>>>importos>>>frompydwarfs.dwarfsextractimportDwarFSExtract>>>dwarfsextract=DwarFSExtract.init()>>>output_dir='/path/to/dest/directory'>>>dwarfsextract.extract('/path/to/image.dwarfs',output_dir)>>>>>>os.listdir(output_dir)['dataWin', 'Sakuna.exe', 'steam_appid.txt', 'xaudio2_9redist.dll', ...]>>>Note:The path pointed to byoutput_dirmust be an existing directory.Extract image file with progress>>>another_output_dir='/path/to/another/output/directory'>>>forprogressindwarfsextract.extract('/path/to/image.dwarfs',another_output_dir,yield_progress=True):...print(progress)...1009998...210>>>os.listdir(another_output_dir)['dataWin', 'Sakuna.exe', 'steam_appid.txt', 'xaudio2_9redist.dll', ...]>>>