mirror of
https://github.com/gryf/uc1541.git
synced 2026-02-17 05:55:46 +01:00
Reorganize the code, added constants.
This commit is contained in:
17
uc1541
17
uc1541
@@ -52,6 +52,9 @@ else:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
SECLEN = 256
|
||||||
|
|
||||||
|
|
||||||
def _ord(string_or_int):
|
def _ord(string_or_int):
|
||||||
"""
|
"""
|
||||||
Return an int value for the (possible) string passed in argument. This
|
Return an int value for the (possible) string passed in argument. This
|
||||||
@@ -135,7 +138,10 @@ class Disk(object):
|
|||||||
0b011: 'usr',
|
0b011: 'usr',
|
||||||
0b100: 'rel'}
|
0b100: 'rel'}
|
||||||
|
|
||||||
def __init__(self, dimage):
|
OFFSET_MAP = {}
|
||||||
|
DIR_TRACK = 18
|
||||||
|
|
||||||
|
def __init__(self, raw):
|
||||||
"""
|
"""
|
||||||
Init
|
Init
|
||||||
"""
|
"""
|
||||||
@@ -187,13 +193,13 @@ class Disk(object):
|
|||||||
|
|
||||||
if self.next_track is None:
|
if self.next_track is None:
|
||||||
LOG.debug("Going to the track: 18,1")
|
LOG.debug("Going to the track: 18,1")
|
||||||
offset = self._get_d64_offset(18, 1)
|
offset = self._get_offset(self.DIR_TRACK, 1)
|
||||||
else:
|
else:
|
||||||
offset = self._get_d64_offset(self.next_track, self.next_sector)
|
offset = self._get_offset(self.next_track, self.next_sector)
|
||||||
LOG.debug("Going to the track: %s,%s", self.next_track,
|
LOG.debug("Going to the track: %s,%s", self.next_track,
|
||||||
self.next_sector)
|
self.next_sector)
|
||||||
|
|
||||||
self.current_sector_data = self.raw[offset:offset + 256]
|
self.current_sector_data = self.raw[offset:offset + SECLEN]
|
||||||
|
|
||||||
# Guard for reading data out of bound - that happened for discs which
|
# Guard for reading data out of bound - that happened for discs which
|
||||||
# store only raw data, even on 18 track
|
# store only raw data, even on 18 track
|
||||||
@@ -467,7 +473,7 @@ class Uc1541(object):
|
|||||||
'display_name': display_name,
|
'display_name': display_name,
|
||||||
'uid': uid,
|
'uid': uid,
|
||||||
'gid': gid,
|
'gid': gid,
|
||||||
'size': int(blocks) * 256,
|
'size': int(blocks) * SECLEN,
|
||||||
'perms': perms})
|
'perms': perms})
|
||||||
idx += 1
|
idx += 1
|
||||||
return directory
|
return directory
|
||||||
@@ -595,6 +601,7 @@ def no_parse():
|
|||||||
|
|
||||||
return CALL_MAP[sys.argv[1]](arg)
|
return CALL_MAP[sys.argv[1]](arg)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
LOG.debug("Script params: %s", str(sys.argv))
|
LOG.debug("Script params: %s", str(sys.argv))
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user