3 if type(file) == type(''):
4 file = open(file, 'rb');
8 if len(head
) != 2: break
9 el_class
= ord(head
[0]) >> 4
10 el_id
= ((ord(head
[0]) & 0x0f) << 3) |
(ord(head
[1]) >> 5)
11 el_len
= ord(head
[1]) & 0x1f
12 if el_len
== 31: # long form element
14 if len(head
) != 2: break
15 el_len
= (ord(head
[0]) << 8) |
ord(head
[1])
16 print (el_class
, el_id
, el_len
)
18 el_body
= file.read(el_len
)
19 if el_len
& 1 == 1: # odd element length
20 file.read(1) # discard NULL byte
22 list.append((el_class
, el_id
, el_body
))
24 if (el_class
, el_id
) == (0, 2):