-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
61 lines (43 loc) · 1.92 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pyxbincodec
def readPixbin( filePath ):
with open(filePath, mode='rb') as file: # b is important -> binary
buff = file.read()
pixBinDecoder = pyxbincodec.PixBinDecoder()
pixBinDecoder.setInput( buff )
# optional, perform a md5 verification when calling fetchBlock()
pixBinDecoder.enableBlockVerification( True )
if( not pixBinDecoder.isValid() ):
print("The file is not valid")
return
nbBlocks = pixBinDecoder.getNumberOfBlocks()
print("\nNumber of blocks:")
print(nbBlocks)
print("\nBin creation date:")
print(pixBinDecoder.getBinCreationDate())
print("\nBin description:")
print(pixBinDecoder.getBinDescription())
print("\nUser object:")
print(pixBinDecoder.getBinUserObject())
for i in range(0, nbBlocks):
#for i in range(3, 4):
print("\n-------------------- BLOCK " + str(i) + " ----------")
print("\nDescription of block #" + str(i))
print(pixBinDecoder.getBlockDescription(i))
print("\nType of block #" + str(i))
print(pixBinDecoder.getBlockType(i))
block = pixBinDecoder.fetchBlock(i, )
if( block is None ):
print("Invalid block")
continue
print("\nBlock type (from block info):")
print(block["originalBlockType"])
print("\nBlock metadata:")
print(block["_metadata"])
print("\nBlock data:")
print(block["_data"])
if __name__ == "__main__":
#filePath = "../data/testFile_uncomp.pixb"
#filePath = "../data/testFile_comp.pixb"
#filePath = "../data/testFile_50k25_uncomp.pixb"
filePath = "../data/testFile_50k25_comp.pixb"
readPixbin( filePath )