source: ammosreader/sample_scripts/pdw_reader.py@ 09b290d

AmmosSource guix
Last change on this file since 09b290d was f3421e6, checked in by recknagel <recknagel@…>, 3 years ago

updated sample_scripts

  • Property mode set to 100644
File size: 646 bytes
RevLine 
[1e781ba]1import os
2import sys
[f3421e6]3sys.path.append('../src/')
[1e781ba]4
[f3421e6]5from ammosreader.PDW import PDW
[1e781ba]6
7if __name__ == '__main__':
8
9 if len(sys.argv) != 2:
10 print("Specify name of .ppdw file")
11 sys.exit()
12
13 file_name = sys.argv[1]
14
15 with open(file_name, 'rb') as f:
16
17 while(True):
18 current_bytes = f.read(32)
19 if current_bytes == '':
20 print("End of file detected")
21 break
22 if len(current_bytes) != 32:
23 print("Can not read all 32 bytes of next PDW")
24 break
25
26 current_pdw = PDW.from_bytes(current_bytes)
27 print(current_pdw)
Note: See TracBrowser for help on using the repository browser.