Added extra metadata command to print out lots of info about dirent

This commit is contained in:
Rob McMullen 2017-02-26 17:08:55 -08:00
parent f00ef7cbea
commit 9a87d10326
4 changed files with 20 additions and 2 deletions

View File

@ -129,6 +129,8 @@ def list_files(image, files):
for dirent in image.files:
if not files or dirent.filename in files:
print dirent
if options.metadata:
print dirent.extra_metadata(image)
def assemble(image, source_files, data_files):
if source_files:
@ -197,6 +199,7 @@ def run():
parser.add_argument("-o", "--output", action="store", default="", help="output file name for those commands that need it")
parser.add_argument("--shred", action="store_true", default=False, help="fill empty sectors with 0")
parser.add_argument("--vtoc", action="store_true", default=False, help="show the VTOC")
parser.add_argument("-m", "--metadata", action="store_true", default=False, help="show extra metadata for named files")
options, extra_args = parser.parse_known_args()
print options, extra_args

View File

@ -124,7 +124,10 @@ class AtariDosDirent(Dirent):
if self.deleted: flags.append("DEL")
if self.locked: flags.append("LOCK")
return "flags=[%s]" % ", ".join(flags)
def extra_metadata(self, image):
return self.verbose_info
def parse_raw_dirent(self, image, bytes):
if bytes is None:
return

View File

@ -213,6 +213,13 @@ class Dos33Dirent(Dirent):
@property
def flag(self):
return 0xff if self.deleted else self._file_type | (0x80 * int(self.locked))
def extra_metadata(self, image):
lines = []
ts = self.get_track_sector_list(image)
lines.append("track/sector list at: " + str(ts))
lines.append("sector map: " + str(self.sector_map))
return "\n".join(lines)
def parse_raw_dirent(self, image, bytes):
if bytes is None:
@ -289,15 +296,17 @@ class Dos33Dirent(Dirent):
log.debug("reading track/sector list at %d for %s" % (sector_num, self))
data, _ = image.get_sectors(sector_num)
sector = Dos33TSSector(image.header, data=data)
sector.sector_num = sector_num
sector_map.extend(sector.get_tslist())
tslist.append(sector)
sector_num = sector.next_sector_num
self.sector_map = sector_map[0:self.num_sectors - len(tslist)]
self.track_sector_list = tslist
return tslist
def get_sectors_in_vtoc(self, image):
self.get_track_sector_list(image)
sectors = []
sectors = BaseSectorList(image.header)
sectors.extend(self.track_sector_list)
for sector_num in self.sector_map:
sector = WriteableSector(image.header.sector_size, None, sector_num)

View File

@ -143,6 +143,9 @@ class Dirent(object):
def __eq__(self, other):
raise NotImplementedError
def extra_metadata(self, image):
raise NotImplementedError
def mark_deleted(self):
raise NotImplementedError