Example #1
0
    def run(self):
        """
        .. versionchanged: Lab 10: Rename map to f_map to avoid shadowing
        """
        files = FileDao.get_all_files()
        if len(files) != 0:
            format_string = '{:<38} {:<7} {:<23} {:<40} {:<8}'
            # Printing the header
            self.log('', prefix=False)
            self.log(format_string.format('MemoryAddress', 'Bytes', 'Path',
                                          'Sector Memory Address',
                                          'Sector Order'),
                     prefix=False)
            self.log('', prefix=False)

            # Printing memory specs for all files
            for file in files:
                path = FileDao.get_path(file)
                sectors = file.sectors
                f_map = format_string.format(
                    file.id, FileDao.get_file_size(file), path,
                    '' if file.is_empty else sectors[0].id,
                    '' if file.is_empty else sectors[0].order)
                self.log(f_map, prefix=False)
                for sector in sectors:
                    if sector == sectors[0]:
                        continue
                    self.log(format_string.format('', '', '', str(sector.id),
                                                  str(sector.order)),
                             prefix=False)
            self.log('', prefix=False)
        else:
            self.log('Memory is Empty!', prefix=False)
Example #2
0
 def run(self):
     path = FileDao.get_path(self)
     self.log(path, prefix=False)