|
1 """ |
|
2 Copyright (c) 2006, Jari Sukanen |
|
3 All rights reserved. |
|
4 |
|
5 Redistribution and use in source and binary forms, with or |
|
6 without modification, are permitted provided that the following |
|
7 conditions are met: |
|
8 * Redistributions of source code must retain the above copyright |
|
9 notice, this list of conditions and the following disclaimer. |
|
10 * Redistributions in binary form must reproduce the above copyright |
|
11 notice, this list of conditions and the following disclaimer in |
|
12 the documentation and/or other materials provided with the |
|
13 distribution. |
|
14 * Names of the contributors may not be used to endorse or promote |
|
15 products derived from this software without specific prior written |
|
16 permission. |
|
17 |
|
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|
20 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
|
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
26 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
27 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|
28 THE POSSIBILITY OF SUCH DAMAGE. |
|
29 """ |
|
30 |
|
31 import struct |
|
32 import sisfields, sisreader |
|
33 |
|
34 class SISInfo(sisfields.SISField) : |
|
35 def __init__(self) : |
|
36 sisfields.SISField.__init__(self) |
|
37 self.fin = None |
|
38 self.fileHeader = sisfields.SISFileHeader() |
|
39 |
|
40 def parse(self, filename) : |
|
41 fin = open(filename, 'rb') |
|
42 fileReader = sisreader.SISFileReader(fin) |
|
43 self.parseHeader(fileReader) |
|
44 self.parseSISFields(fileReader) |
|
45 |
|
46 def parseHeader(self, fileReader) : |
|
47 self.fileHeader.uid1 = fileReader.readBytesAsUint(4) |
|
48 self.fileHeader.uid2 = fileReader.readBytesAsUint(4) |
|
49 self.fileHeader.uid3 = fileReader.readBytesAsUint(4) |
|
50 self.fileHeader.uidChecksum = fileReader.readBytesAsUint(4) |
|
51 |
|
52 def parseSISFields(self, fileReader) : |
|
53 parser = sisreader.SISFieldParser() |
|
54 while not fileReader.isEof() : |
|
55 self.subFields.append(parser.parseField(fileReader)) |