The primary sphobjinv
API consists of two pairs of functions:
~sphobjinv.sphobjinv.readfile
/~sphobjinv.sphobjinv.writefile
-- Read/write files from/to disk as , for proper behavior ofzlib
(de)compression.~sphobjinv.sphobjinv.encode
/~sphobjinv.sphobjinv.decode
-- Encode/decode the object data read from disk.
Also exposed are two patterns, potentially useful in parsing decoded data only:
~sphobjinv.sphobjinv.p_comments
-- Retrieves the #-prefixed comment lines~sphobjinv.sphobjinv.p_data
-- Retrieves all lines not prefixed by #
The normal workflow would be:
Import the module; e.g.:
>>> import sphobjinv as soi
Read the desired file data (compressed or uncompressed) with
~sphobjinv.sphobjinv.readfile
:>>> fd = soi.readfile('/path/to/file')
Decode [or encode] the file data with
~sphobjinv.sphobjinv.decode
[or~sphobjinv.sphobjinv.encode
]:>>> data = soi.decode(fd)
Write the desired file with
~sphobjinv.sphobjinv.writefile
, or otherwise use the resulting data:>>> len(soi.p_data.findall(data)) # e.g., retrieve the number of object entries 6319 >>> soi.writefile('/path/to/new/file', data)
Members
sphobjinv.sphobjinv