File: test_gost_import.py

package info (click to toggle)
openstructure 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,240 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (15 lines) | stat: -rw-r--r-- 379 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import struct

with open("test.gost","rb") as gf:

  header = gf.read(6)
  if str(header[0:4]) != "GOST":
    raise RuntimeError("file format mismatch")
  raw = gf.read(16)

  while raw:
    (type, subtype,size) = struct.unpack("iiL",raw)
    print("found type=%d, subtype=%d and blocksize=%u"%(type,subtype,size))
    if size>0:
      data = gf.read(size)
    raw = gf.read(16)