Pkg.RPM
— API for parsing RPM archives¶
Parsing an RPM Archive¶
The following code example demonstrates how to parse an RPM archive:
from Pro.Core import *
from Pkg.RPM import *
def parseRPMArchive(fname):
c = createContainerFromFile(fname)
if c.isNull():
return
obj = RPMObject()
if not obj.Load(c) or not obj.ParseArchive():
return
n = obj.GetEntryCount()
for i in range(n):
entry = obj.GetEntry(i)
if entry == None:
break
# skip directories
if not obj.IsFile(entry):
continue
print("file name:", entry.name)
# retrieves the file data as NTContainer
fc = obj.GetEntryData(entry)
Module API¶
Pkg.RPM module API.
Classes:
This class represents an RPM archive.
- class RPMObject¶
Bases:
Pro.Core.CFFObject
This class represents an RPM archive.
Methods:
DumpHeaders
(out)Dumps the headers to a text stream.
GetEntry
(i)Retrieves an entry by its index.
Returns the number of entries present in the archive.
GetEntryData
(i[, wo])Retrieves the data of an entry.
Returns the headers as a dictionary.
IsDirectory
(i)Checks whether an entry is a directory.
IsFile
(i)Checks whether an entry is a file.
Parses the archive.
- DumpHeaders(out: Pro.Core.NTTextStream) → None¶
Dumps the headers to a text stream.
- Parameters
out (NTTextStream) – The output text stream.
See also
GetHeaders()
.
- GetEntry(i: int) → Any¶
Retrieves an entry by its index.
- Parameters
i (int) – The entry index.
- Returns
Returns the requested entry if successful; otherwise returns
None
.- Return type
Any
See also
GetEntryCount()
.
- GetEntryCount() → int¶
- Returns
Returns the number of entries present in the archive.
- Return type
int
See also
GetEntry()
.
- GetEntryData(i: int, wo: Optional[Pro.Core.NTIWait] = None) → Pro.Core.NTContainer¶
Retrieves the data of an entry.
- Parameters
i (int) – The entry index.
wo (NTIWait) – Optional wait object for the operation.
- Returns
Returns the data if successful; otherwise returns an invalid container.
- Return type
See also
GetEntryCount()
.
- GetHeaders() → Dict[str, Any]¶
- Returns
Returns the headers as a dictionary.
- Return type
Dict[str, Any]
See also
DumpHeaders()
.
- IsDirectory(i: int) → bool¶
Checks whether an entry is a directory.
- Parameters
i (int) – The entry index.
- Returns
Returns
True
if the entry is a directory; otherwise returnsFalse
.- Return type
bool
See also
IsFile()
.
- IsFile(i: int) → bool¶
Checks whether an entry is a file.
- Parameters
i (int) – The entry index.
- Returns
Returns
True
if the entry is a file; otherwise returnsFalse
.- Return type
bool
See also
IsDirectory()
.
- ParseArchive() → bool¶
Parses the archive.
- Returns
Returns
True
if successful; otherwise returnsFalse
.- Return type
bool