|
| 1 | +class FileData(object): |
| 2 | + """ FileData: |
| 3 | + signature '4s' : name of record, also record type |
| 4 | + data_size 'I' : size of record |
| 5 | +
|
| 6 | + :Vars: |
| 7 | + magic_number : number of bytes for all records. |
| 8 | + : Oblivion is 20 all other games use 24 |
| 9 | + tes4_sig : plugin header signature |
| 10 | + group_sig : Group signature, is not the signature of the groups that |
| 11 | + : follow, only indicated the beginning of a Group |
| 12 | + """ |
| 13 | + magic_number = 24 |
| 14 | + tes4_sig = 'TES4' |
| 15 | + group_sig = 'GRUP' |
| 16 | + |
| 17 | + def __init__(self): |
| 18 | + self.signature |
| 19 | + self.data_size |
| 20 | + |
| 21 | + @staticmethod |
| 22 | + def unpack(ins): |
| 23 | + """Return a RecordHeader object by reading the input stream.""" |
| 24 | + raise exception.AbstractError |
| 25 | + |
| 26 | + def pack(self): |
| 27 | + """Return the record header packed into a string to be written to file""" |
| 28 | + raise exception.AbstractError |
| 29 | + |
| 30 | +class FileGroup(FileData): |
| 31 | + """ FileRecord: |
| 32 | + :Inherits: FileData |
| 33 | + signature '4s' : name of record, also record type |
| 34 | + data_size 'I' : size of record |
| 35 | +
|
| 36 | + :New Instances: |
| 37 | + group_name '4s' : signature of following groups i.e. GMST, KYWD |
| 38 | + group_type 'I' : group type 1, 10 |
| 39 | + time_stamp 'H' : presumed to be a time stamp |
| 40 | + grec_unk_one 'H' : presumed to be creation kit version control |
| 41 | + form_version 'H' : version of the record format |
| 42 | + grec_unk_two 'H' : presumed to be creation kit version control |
| 43 | + record_data : the records sub groups (data_size - 24) |
| 44 | + """ |
| 45 | + |
| 46 | + def __init__(self): |
| 47 | + super(FileGroup, self).__init__(self) |
| 48 | + self.group_name |
| 49 | + self.group_type |
| 50 | + self.time_stamp |
| 51 | + self.grec_unk_one |
| 52 | + self.form_Version |
| 53 | + self.grec_unk_two |
| 54 | + self.group_data |
| 55 | + |
| 56 | +class FileRecord(FileGroup): |
| 57 | + """ FileRecord: |
| 58 | + :Inherits: FileData |
| 59 | + signature '4s' : name of record, also record type |
| 60 | + data_size 'I' : size of record |
| 61 | +
|
| 62 | + :New Instances: |
| 63 | + record_flags 'I' : flags set for the record |
| 64 | + next_form 'I' : next form available |
| 65 | + vrec_info_one 'I' : presumed to be creation kit version control |
| 66 | + form_version 'H' : version of the record format |
| 67 | + vrec_info_two 'H' : presumed to be creation kit version control |
| 68 | + record_data : the records data |
| 69 | +
|
| 70 | + when record_flags & 0b00040000 the data is compressed |
| 71 | +
|
| 72 | + decompressed_size 'I' : size of decompressed data |
| 73 | + record_data : compressed data of (data_size - 4) with zlib |
| 74 | + """ |
| 75 | + |
| 76 | + def __init__(self): |
| 77 | + super(FileRecord, self).__init__(self) |
| 78 | + self.record_flags |
| 79 | + self.next_form |
| 80 | + self.vrec_info_one |
| 81 | + self.form_version |
| 82 | + self.vrec_info_two |
| 83 | + self.record_data |
| 84 | + |
| 85 | +class DataField(FileRecord): |
| 86 | + """ FileRecord: |
| 87 | + :Inherits: FileData |
| 88 | + signature '4s' : name of record, also record type |
| 89 | + data_size 'I' : size of record |
| 90 | +
|
| 91 | + :New Instances: |
| 92 | + field_data : field data of data_size |
| 93 | +
|
| 94 | + :Special Cases: |
| 95 | + XXXX : Is used when ANY subrecord's size exceeds 65535. |
| 96 | + : data_size it the size of data that follows XXXX |
| 97 | + : field_data will be null and data will have the |
| 98 | + : four letter signature of the data XXXX is prepended |
| 99 | + : to, and uses the signature of a subrecord. |
| 100 | + """ |
| 101 | + def __init__(self): |
| 102 | + super(DataField, self).__init__(self) |
| 103 | + self.field_data |
| 104 | + |
0 commit comments