Pro.GZ — API for parsing GZip archives

Overview

The Pro.GZ module contains the API for parsing GZip archives.

Decompressing a GZip archive

The following code example demonstrates how to decompress a GZip archive:

from Pro.Core import *
from Pro.GZ import *

def decompressGZ(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return NTContainer()
    obj = GZObject()
    if not obj.Load(c):
        return NTContainer()
    r = obj.GetCompressedRange()
    c = c.clone()
    c.setRange(r.offset, r.size)
    c = applyFilters(c, "<flts><f name='unpack/zlib' raw='true'/></flts>", False)
    return c

Module API

Pro.GZ module API.

Attributes:

FLG_FCOMMENT

Header flag.

FLG_FEXTRA

Header flag.

FLG_FHCRC

Header flag.

FLG_FNAME

Header flag.

FLG_FTEXT

Header flag.

Classes:

GZObject()

This class represents a GZip archive.

FLG_FCOMMENT: Final[int]

Header flag.

FLG_FEXTRA: Final[int]

Header flag.

FLG_FHCRC: Final[int]

Header flag.

FLG_FNAME: Final[int]

Header flag.

FLG_FTEXT: Final[int]

Header flag.

class GZObject

Bases: Pro.Core.CFFObject

This class represents a GZip archive.

Methods:

DumpInfo(out)

Outputs the header info.

FlagsToString(flags)

Converts the header flags to a string.

GetCompressedRange()

Returns the compressed data range.

GetModificationTime()

Returns the modification time.

GetOSName(os)

Converts the OS value to string.

DumpInfo(out: Pro.Core.NTTextStream)None

Outputs the header info.

Parameters

out (NTTextStream) – The output stream.

FlagsToString(flags: int)str

Converts the header flags to a string.

Parameters

flags (int) – The header flags.

Returns

Returns the header flags as string.

Return type

str

GetCompressedRange()Pro.Core.NTOffsetRange
Returns

Returns the compressed data range.

Return type

NTOffsetRange

GetModificationTime()Pro.Core.NTDateTime
Returns

Returns the modification time.

Return type

NTDateTime

GetOSName(os: int)str

Converts the OS value to string.

Parameters

os (int) – The OS value.

Returns

Returns the converted value if successful; otherwise returns "Unknown".

Return type

str