Pro.ITSF
— API for parsing Microsoft CHM files¶
Extraction¶
The following code example demonstrates how to extract the contents of a CHM file:
from Pro.Core import *
from Pro.ITSF import *
def parseCHM(chm_name):
c = createContainerFromFile(chm_name)
obj = ITSFObject()
if not obj.Load(c):
return
if not obj.LoadHeaders() or not obj.DecompressSections():
return
n = obj.GetListingEntryCount()
entry = ITSFDirectoryListingEntry()
for i in range(n):
if obj.GetDirectoryListingEntry(i, entry):
print("name:", entry.name, "- size:", entry.size)
# uncomment the following line to retrieve the file data
#content = obj.GetFile(entry)
Module API¶
Pro.ITSF module API.
Classes:
This class represents a listing entry.
This class represents a CHM file.
- class ITSFDirectoryListingEntry¶
This class represents a listing entry.
See also
ITSFObject.GetDirectoryListingEntry()
.Attributes:
The name of the entry.
The size of the name of the entry.
The section-relative offset of the file data.
The index of the section containing the data.
The size of the file data.
- name¶
The name of the entry.
- name_size¶
The size of the name of the entry.
- offset¶
The section-relative offset of the file data.
- section¶
The index of the section containing the data.
- size¶
The size of the file data.
- class ITSFObject¶
Bases:
Pro.Core.CFFObject
This class represents a CHM file.
Methods:
DecompressSections
([w])Decompresses the compressed sections of the CHM file.
GetDirectoryListingEntry
(i_or_path, entry)Retrieves a listing entry.
GetFile
(file_entry_or_path)Retrieves the file data.
Returns the number of listing entries present in the CHM file.
Header
()Returns the header of the CHM file.
Loads the headers of the CHM file.
Returns the section header 0.
Returns the section header 1.
- DecompressSections(w: Optional[Pro.Core.NTIWait] = None) → bool¶
Decompresses the compressed sections of the CHM file.
- Parameters
w (NTIWait) – An optional wait operation.
- Returns
Returns
True
if successful; otherwise returnsFalse
.- Return type
bool
See also
LoadHeaders()
.
- GetDirectoryListingEntry(i_or_path: Union[int, str], entry: Pro.ITSF.ITSFDirectoryListingEntry) → bool¶
Retrieves a listing entry.
- Parameters
i_or_path (Union[int, str]) – The index or name of the listing entry to retrieve.
entry (ITSFDirectoryListingEntry) – The instance of the structure to be retrieved.
- Returns
Returns
True
if successful; otherwise returnsFalse
.- Return type
bool
See also
GetListingEntryCount()
andGetFile()
.
- GetFile(file_entry_or_path: Union[Pro.ITSF.ITSFDirectoryListingEntry, str]) → Pro.Core.NTContainer¶
Retrieves the file data.
- Parameters
file_entry_or_path (Union[ITSFDirectoryListingEntry, str]) – The index or name of the file retrieve.
- Returns
Returns the file data if successful; otherwise returns an invalid container.
- Return type
See also
GetListingEntryCount()
andGetDirectoryListingEntry()
.
- GetListingEntryCount() → int¶
- Returns
Returns the number of listing entries present in the CHM file.
- Return type
int
See also
GetDirectoryListingEntry()
andGetFile()
.
- Header() → Pro.Core.CFFStruct¶
- Returns
Returns the header of the CHM file.
- Return type
- LoadHeaders() → bool¶
Loads the headers of the CHM file.
- Returns
Returns
True
if successful; otherwise returnsFalse
.- Return type
bool
See also
DecompressSections()
.
- SectionHeader0() → Pro.Core.CFFStruct¶
- Returns
Returns the section header 0.
- Return type
- SectionHeader1() → Pro.Core.CFFStruct¶
- Returns
Returns the section header 1.
- Return type