Package zeroinstall :: Package zerostore :: Module unpack
[frames] | no frames]

Module unpack

source code

Unpacking archives of various formats.

Functions
bool
recent_gnu_tar() source code
str | None
type_from_url(url)
Guess the MIME type for this resource based on its URL.
source code
 
check_type_ok(mime_type)
Check we have the needed software to extract from an archive of the given type.
source code
 
unpack_archive_over(url, data, destdir, extract=None, type=None, start_offset=0)
Like unpack_archive, except that we unpack to a temporary directory first and then move things over, checking that we're not following symlinks at each stage.
source code
 
unpack_archive(url, data, destdir, extract=None, type=None, start_offset=0)
Unpack stream 'data' into directory 'destdir'.
source code
 
extract_deb(stream, destdir, extract=None, start_offset=0) source code
 
extract_rpm(stream, destdir, extract=None, start_offset=0) source code
 
extract_gem(stream, destdir, extract=None, start_offset=0) source code
 
extract_cab(stream, destdir, extract, start_offset=0) source code
 
extract_dmg(stream, destdir, extract, start_offset=0) source code
 
extract_zip(stream, destdir, extract, start_offset=0) source code
 
extract_tar(stream, destdir, extract, decompress, start_offset=0) source code
Function Details

recent_gnu_tar()

source code 
Returns: bool

Deprecated: should be private

type_from_url(url)

source code 

Guess the MIME type for this resource based on its URL. Returns None if we don't know what it is.

Parameters:
  • url (str)
Returns: str | None

check_type_ok(mime_type)

source code 

Check we have the needed software to extract from an archive of the given type.

Parameters:
  • mime_type (str)
Raises:

unpack_archive_over(url, data, destdir, extract=None, type=None, start_offset=0)

source code 

Like unpack_archive, except that we unpack to a temporary directory first and then move things over, checking that we're not following symlinks at each stage. Use this when you want to unpack an unarchive into a directory which already has stuff in it.

Parameters:
  • url (str)
  • data (file)
  • start_offset (int)
  • destdir (str)
  • type (str | None)
  • extract (str | None)

Note: Since 0.49, the leading "extract" component is removed (unlike unpack_archive).

Since: 0.28

unpack_archive(url, data, destdir, extract=None, type=None, start_offset=0)

source code 

Unpack stream 'data' into directory 'destdir'. If extract is given, extract just that sub-directory from the archive (i.e. destdir/extract will exist afterwards). Works out the format from the name.

Parameters:
  • url (str)
  • data (file)
  • start_offset (int)
  • destdir (str)
  • type (str | None)
  • extract (str | None)

extract_deb(stream, destdir, extract=None, start_offset=0)

source code 
Parameters:
  • start_offset (int)
  • destdir (str)
  • stream (file)

extract_gem(stream, destdir, extract=None, start_offset=0)

source code 
Parameters:
  • start_offset (int)
  • destdir (str)
  • stream (file)

Since: 0.53

extract_cab(stream, destdir, extract, start_offset=0)

source code 

Since: 0.24

extract_dmg(stream, destdir, extract, start_offset=0)

source code 

Since: 0.46

extract_zip(stream, destdir, extract, start_offset=0)

source code 
Parameters:
  • start_offset (int)
  • extract (str)
  • destdir (str)
  • stream (file)

extract_tar(stream, destdir, extract, decompress, start_offset=0)

source code 
Parameters:
  • start_offset (int)
  • extract (str)
  • destdir (str)
  • stream (file)
  • decompress (str)