예제 #1
0
    def getFileColumnText(self, colid, tempfile, index = 0):
        torrent = self.parent.parent.getTorrent()
        if torrent is None:
            return ""
        
        text = None
        
        if colid == FILEINFO_FILENAME:
            if torrent.files.isFile():
                text = split(torrent.files.getProcDest(pathonly = False, checkexists = False))[1]
            else:
                if tempfile['path']:
                    text = tempfile['path'][-1]
        elif colid == FILEINFO_SIZE:
            if torrent.files.isFile() or torrent.files.filepriorities[index] != -1:
                text = comma_format(tempfile['length']) + ' ' + _('Byte')
        elif colid == FILEINFO_PROGRESS:
            if torrent.files.isFile():
                if not torrent.status.isCheckingOrAllocating():
                    if torrent.status.completed:
                        text = _('Done')
                    else:
                        text = torrent.getColumnText(COL_PROGRESS, force = True)
            else:
                progress = torrent.files.fileprogress[index]
                if progress == -1:
                    # Don't download (or hasn't started)
                    text = ''
                elif progress > 100:
                    # Complete
                    text = _('Done')
                else:
                    # Downloading
                    text = '%d%%' % progress
        elif colid == FILEINFO_MD5:
            if 'md5sum' in tempfile:
                text = str(tempfile['md5sum'])
        elif colid == FILEINFO_CRC32:
            if 'crc32' in tempfile:
                text = str(tempfile['crc32'])
        elif colid == FILEINFO_SHA1:
            if 'sha1' in tempfile:
                text = binascii.b2a_hex(tempfile['sha1'])
        elif colid == FILEINFO_ED2K:
            if 'ed2k' in tempfile:
                text = binascii.b2a_hex(tempfile['ed2k'])
            
        if text is None:
            text = ""

        return text
예제 #2
0
 def getColumnText(self, column):
     if self.torrent is None:
         return ""
     
     if column == self.name:
         text = self.torrent.getTitle(kind = "current")
     elif column == self.destination:
         text = self.torrent.files.getProcDest(pathonly = True, checkexists = False)
     elif column == self.size:
         totalsize = self.torrent.files.getSize()
         text = _("%s (%s bytes)") % (utility.size_format(totalsize), comma_format(totalsize))
     elif column == self.pieces:
         piece_length = self.torrent.info['piece length']
         pieces = int((self.torrent.files.getSize() + piece_length - 1)/piece_length)
         if pieces > 1:
             text = _("%i x %s") % (pieces, utility.size_format(piece_length))
         else:
             text = str(pieces)
     elif column == self.encoding:
         text = _('N/A')
         if 'encoding' in self.torrent.metainfo and self.torrent.metainfo['encoding'].strip():
             text = self.torrent.metainfo['encoding']
     elif column == self.private:
         text = _('No')
         if self.torrent.private:
             text = _('Yes')
     elif column == self.creationDate:
         try:
             text = strftime('%x %X', localtime(self.torrent.metainfo['creation date']))
         except:
             try:
                 text = str(self.torrent.metainfo['creation date'])
             except:
                 text = _('<cannot read date>')
     elif column == self.createdBy:
         text = _('N/A')
         if 'created by' in self.torrent.metainfo and self.torrent.metainfo['created by'].strip():
             text = self.torrent.metainfo['created by']
     elif column == self.infoHash:
         text = self.torrent.infohash
     elif column == self.magnet:
         text = self.torrent.getMagnetLink()
     elif column == self.comment:
         text = _('N/A')
         if 'comment' in self.torrent.metainfo and self.torrent.metainfo['comment'].strip():
             text = self.torrent.metainfo['comment']
     else:
         text = ""
     return text
예제 #3
0
 def _calcTotalSize(self):
     """
     Calculate the total size of the selected files
     """
     totalsize = 0L
     
     checkedfiles = self.getCheckedFiles()
     
     filecount = len(checkedfiles)
     
     for patharray, fullpath, filename, size, addto in checkedfiles:
         totalsize += size
     
     sizestring = _('%s (%s bytes)') % (utility.size_format(totalsize), comma_format(totalsize))
     
     self.numfileslabel.SetLabel(str(filecount))
     
     self.sizetext.SetLabel(sizestring)