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