mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-25 16:32:07 +00:00
All tests passing for python 3
This commit is contained in:
parent
841aa1dc9b
commit
c30f390fed
@ -94,8 +94,8 @@ class AtariDosDirent(Dirent):
|
||||
self.deleted = False
|
||||
self.num_sectors = 0
|
||||
self.starting_sector = 0
|
||||
self.basename = ""
|
||||
self.ext = ""
|
||||
self.basename = b''
|
||||
self.ext = b''
|
||||
self.is_sane = True
|
||||
self.current_sector = 0
|
||||
self.current_read = 0
|
||||
@ -103,14 +103,14 @@ class AtariDosDirent(Dirent):
|
||||
self.parse_raw_dirent(image, bytes)
|
||||
|
||||
def __str__(self):
|
||||
return "File #%-2d (%s) %03d %-8s%-3s %03d" % (self.file_num, self.summary, self.starting_sector, self.basename, self.ext, self.num_sectors)
|
||||
return "File #%-2d (%s) %03d %-8s%-3s %03d" % (self.file_num, self.summary, self.starting_sector, str(self.basename), str(self.ext), self.num_sectors)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.__class__ == other.__class__ and self.filename == other.filename and self.starting_sector == other.starting_sector and self.num_sectors == other.num_sectors
|
||||
|
||||
@property
|
||||
def filename(self):
|
||||
ext = ("." + self.ext) if self.ext else ""
|
||||
ext = (b'.' + self.ext) if self.ext else b''
|
||||
return self.basename + ext
|
||||
|
||||
@property
|
||||
@ -138,10 +138,10 @@ class AtariDosDirent(Dirent):
|
||||
def extra_metadata(self, image):
|
||||
return self.verbose_info
|
||||
|
||||
def parse_raw_dirent(self, image, bytes):
|
||||
if bytes is None:
|
||||
def parse_raw_dirent(self, image, data):
|
||||
if data is None:
|
||||
return
|
||||
values = bytes.view(dtype=self.format)[0]
|
||||
values = data.view(dtype=self.format)[0]
|
||||
flag = values[0]
|
||||
self.flag = flag
|
||||
self.opened_output = (flag&0x01) > 0
|
||||
@ -153,8 +153,8 @@ class AtariDosDirent(Dirent):
|
||||
self.deleted = (flag&0x80) > 0
|
||||
self.num_sectors = int(values[1])
|
||||
self.starting_sector = int(values[2])
|
||||
self.basename = str(values[3]).rstrip()
|
||||
self.ext = str(values[4]).rstrip()
|
||||
self.basename = bytes(values[3]).rstrip()
|
||||
self.ext = bytes(values[4]).rstrip()
|
||||
self.is_sane = self.sanity_check(image)
|
||||
|
||||
def encode_dirent(self):
|
||||
|
@ -183,9 +183,9 @@ class DiskImageBase(object):
|
||||
if not filename:
|
||||
raise RuntimeError("No filename specified for save!")
|
||||
if type(filename) is not bytes: filename = filename.encode("utf-8")
|
||||
bytes = self.bytes[:]
|
||||
data = self.bytes[:]
|
||||
with open(filename, "wb") as fh:
|
||||
bytes.tofile(fh)
|
||||
data.tofile(fh)
|
||||
|
||||
def assert_valid_sector(self, sector):
|
||||
if not self.header.sector_is_valid(sector):
|
||||
@ -279,7 +279,7 @@ class DiskImageBase(object):
|
||||
for dirent in self.files:
|
||||
if filename == dirent.filename:
|
||||
return dirent
|
||||
raise FileNotFound("%s not found on disk" % filename)
|
||||
raise FileNotFound("%s not found on disk" % str(filename))
|
||||
|
||||
def find_file(self, filename):
|
||||
dirent = self.find_dirent(filename)
|
||||
|
@ -171,7 +171,7 @@ class Dos33Dirent(Dirent):
|
||||
self.deleted = False
|
||||
self.track = 0
|
||||
self.sector = 0
|
||||
self.filename = ""
|
||||
self.filename = b''
|
||||
self.num_sectors = 0
|
||||
self.is_sane = True
|
||||
self.current_sector_index = 0
|
||||
@ -353,7 +353,8 @@ class Dos33Dirent(Dirent):
|
||||
return self.filename
|
||||
|
||||
def set_values(self, filename, filetype, index):
|
||||
self.filename = "%-30s" % filename[0:30]
|
||||
if type(filename) is not bytes: filename = filename.encode("utf-8")
|
||||
self.filename = b'%-30s' % filename[0:30]
|
||||
self._file_type = self.text_to_type.get(filetype, 0x04)
|
||||
self.locked = False
|
||||
self.deleted = False
|
||||
|
@ -18,6 +18,7 @@ class BaseFilesystemModifyTest(object):
|
||||
self.image = self.diskimage_type(rawdata)
|
||||
|
||||
def check_entries(self, entries, prefix=b"TEST", save=None):
|
||||
if type(prefix) is not bytes: prefix = prefix.encode("utf-8")
|
||||
orig_num_files = len(self.image.files)
|
||||
filenames = []
|
||||
count = 1
|
||||
|
Loading…
Reference in New Issue
Block a user