mirror of
https://github.com/iKarith/cppo-ng.git
synced 2025-02-12 08:31:12 +00:00
Move 2mg parsing further down
This codebase is rapidly getting to the point it's going to need modules and a package. Let's move some logically related code for that purpose.
This commit is contained in:
parent
c20adbabfb
commit
490d7e8224
67
cppo
67
cppo
@ -40,40 +40,6 @@ import struct
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from binascii import a2b_hex, b2a_hex
|
from binascii import a2b_hex, b2a_hex
|
||||||
|
|
||||||
A2MG1_UNPACK = (
|
|
||||||
'<' # use little-endian numbers
|
|
||||||
'4s' # magic string '2IMG'
|
|
||||||
'4s' # creator string
|
|
||||||
'H' # header length
|
|
||||||
'H' # 2mg version
|
|
||||||
'L' # image format
|
|
||||||
'L' # flags (we unpack it into "vol")
|
|
||||||
'L' # number of 512 blocks
|
|
||||||
'L' # image data offset
|
|
||||||
'L' # image data length
|
|
||||||
'L' # comment offset
|
|
||||||
'L' # comment length
|
|
||||||
'L' # creator private use offset
|
|
||||||
'L' # creator private use length
|
|
||||||
'16x' # reserved for future use
|
|
||||||
)
|
|
||||||
A2MG1_ATTRS = (
|
|
||||||
'magic', 'creator', 'hdr_len', 'version',
|
|
||||||
'img_fmt', 'vol', 'num_blocks',
|
|
||||||
'data_offset', 'data_len',
|
|
||||||
'cmnt_offset', 'cmnt_len',
|
|
||||||
'creator_offset', 'creator_len'
|
|
||||||
)
|
|
||||||
A2MG1_VOL_ATTRS = ('locked', 'dosvol')
|
|
||||||
|
|
||||||
# We assume 2mg files with unknown version have these fields
|
|
||||||
A2MG_UNK_ATTRS = ('magic', 'creator', 'hdr_len', 'version')
|
|
||||||
|
|
||||||
A2mg1 = namedtuple('A2mg1', A2MG1_ATTRS)
|
|
||||||
A2mg1Vol = namedtuple('A2mg1Vol', A2MG1_VOL_ATTRS)
|
|
||||||
A2mgUnk = namedtuple('A2mgUnk', A2MG_UNK_ATTRS)
|
|
||||||
|
|
||||||
|
|
||||||
class Globals:
|
class Globals:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -940,6 +906,39 @@ def isnumber(number):
|
|||||||
|
|
||||||
### NEW DISK CLASSES
|
### NEW DISK CLASSES
|
||||||
|
|
||||||
|
A2MG1_UNPACK = (
|
||||||
|
'<' # use little-endian numbers
|
||||||
|
'4s' # magic string '2IMG'
|
||||||
|
'4s' # creator string
|
||||||
|
'H' # header length
|
||||||
|
'H' # 2mg version
|
||||||
|
'L' # image format
|
||||||
|
'L' # flags (we unpack it into "vol")
|
||||||
|
'L' # number of 512 blocks
|
||||||
|
'L' # image data offset
|
||||||
|
'L' # image data length
|
||||||
|
'L' # comment offset
|
||||||
|
'L' # comment length
|
||||||
|
'L' # creator private use offset
|
||||||
|
'L' # creator private use length
|
||||||
|
'16x' # reserved for future use
|
||||||
|
)
|
||||||
|
A2MG1_ATTRS = (
|
||||||
|
'magic', 'creator', 'hdr_len', 'version',
|
||||||
|
'img_fmt', 'vol', 'num_blocks',
|
||||||
|
'data_offset', 'data_len',
|
||||||
|
'cmnt_offset', 'cmnt_len',
|
||||||
|
'creator_offset', 'creator_len'
|
||||||
|
)
|
||||||
|
A2MG1_VOL_ATTRS = ('locked', 'dosvol')
|
||||||
|
|
||||||
|
# We assume 2mg files with unknown version have these fields
|
||||||
|
A2MG_UNK_ATTRS = ('magic', 'creator', 'hdr_len', 'version')
|
||||||
|
|
||||||
|
A2mg1 = namedtuple('A2mg1', A2MG1_ATTRS)
|
||||||
|
A2mg1Vol = namedtuple('A2mg1Vol', A2MG1_VOL_ATTRS)
|
||||||
|
A2mgUnk = namedtuple('A2mgUnk', A2MG_UNK_ATTRS)
|
||||||
|
|
||||||
class Disk:
|
class Disk:
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
if name is not None:
|
if name is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user