Merge pull request #8 from wiz21b/flux1

seek() returns flux data if needed
This commit is contained in:
4am 2022-08-07 15:38:50 -04:00 committed by GitHub
commit b5fd3963cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 3 deletions

View File

@ -724,11 +724,27 @@ class WozDiskImage:
i += 1
def seek(self, track_num):
"""returns Track object for the given track, or None if the track is not part of this disk image. track_num can be 0..40 in 0.25 increments (0, 0.25, 0.5, 0.75, 1, &c.)"""
"""returns Track object for the given track, or None if the
track is not part of this disk image. track_num can be 0..40
in 0.25 increments (0, 0.25, 0.5, 0.75, 1, &c.)"""
half_phase = self.track_num_to_half_phase(track_num)
trk_id = self.tmap[half_phase]
if trk_id == 0xFF: return None
return self.tracks[trk_id]
if trk_id != 0xFF:
return self.tracks[trk_id]
elif (self.info["version"] >= 3) and (self.flux):
# Empty track or flux track
trk_id = self.flux[half_phase]
if trk_id != 0xFF:
# Flux track
return self.tracks[trk_id]
else:
# Empty flux track AND empty track
# This should not happen
return None
else:
# Empty track
return None
def from_json(self, json_string):
j = json.loads(json_string)