Pkg.ASAR
— API for parsing ASAR archives¶
Overview¶
The Pkg.ASAR
module contains the API for parsing the Atom Shell Archive Format, which is a lightweight archive format primarily used in Electron applications.
Parsing an ASAR Archive¶
The following code example demonstrates how to parse an ASAR archive:
from Pro.Core import *
from Pkg.ASAR import *
def parseASARArchive(fname):
c = createContainerFromFile(fname)
if c.isNull():
return
obj = ASARObject()
if not obj.Load(c) or not obj.ParseArchive():
return
entry = None
while entry := obj.NextEntry(entry):
print("Name:", entry[0])
# retrieves the entry data as NTContainer
c = obj.GetEntryData(entry)
Module API¶
Pkg.ASAR module API.
Classes:
This class represents an ASAR archive object.
- class ASARObject¶
Bases:
Pro.Core.CFFObject
This class represents an ASAR archive object.
Methods:
GetEntry
(i)Retrieves an entry by its index.
Returns the number of entries.
GetEntryData
(entry)Retrieves the data for an entry.
GetEntryRange
(entry)Retrieves the data range for an entry.
Returns the header of the ASAR archive.
Returns the header size.
NextEntry
([entry])Retrieves the next entry in the ASAR archive.
Parses the ASAR archive.
- GetEntry(i: int)¶
Retrieves an entry by its index.
- Parameters
i (int) – The index of the entry.
- Returns
Retrieves the requested entry if successful; otherwise returns
None
.- Return type
int
See also
GetEntryCount()
andNextEntry()
.
- GetEntryCount() → int¶
- Returns
Returns the number of entries.
- Return type
int
See also
GetEntry()
andNextEntry()
.
- GetEntryData(entry: tuple) → Pro.Core.NTContainer¶
Retrieves the data for an entry.
- Parameters
entry (tuple[str, dict[Any, Any]]) – The entry.
- Returns
Returns the data associated with an ASAR archive entry.
- Return type
See also
GetEntryRange()
andNextEntry()
.
- GetEntryRange(entry: tuple) → tuple¶
Retrieves the data range for an entry.
- Parameters
entry (tuple[str, dict[Any, Any]]) – The entry.
- Returns
Returns a tuple of an offset and size if successful; otherwise returns
(None, None)
.- Return type
tuple[Optional[int], Optional[int]]
See also
NextEntry()
.
- GetHeader() → dict¶
- Returns
Returns the header of the ASAR archive.
- Return type
dict[Any, Any]
- GetHeaderSize() → int¶
- Returns
Returns the header size.
- Return type
int
- NextEntry(entry: Optional[tuple] = None) → Optional[tuple]¶
Retrieves the next entry in the ASAR archive.
- Parameters
entry (Optional[tuple[str, dict[Any, Any]]]) – The previous entry.
- Returns
Returns an tuple consisting of the entry name and dictionary if successful; otherwise returns
None
.- Return type
Optional[tuple[str, dict[Any, Any]]]
See also
ParseArchive()
andGetEntryData()
.
- ParseArchive() → bool¶
Parses the ASAR archive.
- Returns
Returns
True
if successful; otherwise returnsFalse
.- Return type
bool
See also
NextEntry()
andGetEntryData()
.