コード例 #1
0
 def list(self, file=None, verbose=False):
     """Print a table of contents to sys.stdout. If `verbose' is False, only
        the names of the members are printed. If it is True, an `ls -l'-like
        output is produced.
     """
     if file is None:
         file = sys.stdout
     if verbose:
         file.write("Listing archive: {}\n".format(self.filename))
         self._print_archiveinfo(file=file)
         file.write('\n')
     file.write('total %d files and directories in %sarchive\n' %
                (self._num_files(), (self.solid and 'solid ') or ''))
     file.write(
         '   Date      Time    Attr         Size   Compressed  Name\n')
     file.write(
         '------------------- ----- ------------ ------------  ------------------------\n'
     )
     for f in self.files:
         if f.lastwritetime is not None:
             creationdate = filetime_to_dt(
                 f.lastwritetime).astimezone(Local).strftime("%Y-%m-%d")
             creationtime = filetime_to_dt(
                 f.lastwritetime).astimezone(Local).strftime("%H:%M:%S")
         else:
             creationdate = '         '
             creationtime = '         '
         if f.is_directory:
             attrib = 'D...'
         else:
             attrib = '....'
         if f.archivable:
             attrib += 'A'
         else:
             attrib += '.'
         if f.is_directory:
             extra = '           0 '
         elif f.compressed is None:
             extra = '             '
         else:
             extra = '%12d ' % (f.compressed)
         file.write('%s %s %s %12d %s %s\n' %
                    (creationdate, creationtime, attrib,
                     f.uncompressed_size, extra, f.filename))
     file.write(
         '------------------- ----- ------------ ------------  ------------------------\n'
     )
コード例 #2
0
ファイル: py7zr.py プロジェクト: vanquishsecurity2/py7zr
 def list(self) -> List[FileInfo]:
     """Returns contents information """
     alist = []  # type: List[FileInfo]
     creationtime = None  # type: Optional[datetime.datetime]
     for f in self.files:
         if f.lastwritetime is not None:
             creationtime = filetime_to_dt(f.lastwritetime)
         alist.append(FileInfo(f.filename, f.compressed, f.uncompressed_size, f.archivable, f.is_directory,
                               creationtime))
     return alist