コード例 #1
0
ファイル: torrent.py プロジェクト: kannibalox/tranny
    def size(self, human=False):
        """ Calculate and return the size of the torrent

        :param human: Return a human readable size string
        :type human: str
        :return: Torrent Size
        :rtype: str,int
        """
        try:
            total = (len(self['info']['pieces']) // 20) * self['info']['piece length']
        except KeyError:
            total = self['info']['length']
        return util.file_size(total) if human else total
コード例 #2
0
    def size(self, human=False):
        """ Calculate and return the size of the torrent

        :param human: Return a human readable size string
        :type human: str
        :return: Torrent Size
        :rtype: str,int
        """
        try:
            total = (len(self['info']['pieces']) //
                     20) * self['info']['piece length']
        except KeyError:
            total = self['info']['length']
        return util.file_size(total) if human else total
コード例 #3
0
ファイル: __init__.py プロジェクト: crawln45/tranny
 def __init__(self, info_hash, name, ratio, up_rate, dn_rate, up_total, dn_total, size, size_completed,
              leechers, total_leechers, peers, total_peers, priority, private, is_active, progress, **kwargs):
     super(ClientTorrentData, self).__init__(**kwargs)
     self['DT_RowId'] = info_hash
     self['info_hash'] = info_hash
     self['name'] = name
     self['ratio'] = util.fmt_ratio(ratio)
     self['up_rate'] = up_rate
     self['dn_rate'] = dn_rate
     self['up_total'] = up_total
     self['dn_total'] = dn_total
     self['size'] = util.file_size(size)
     self['size_completed'] = size_completed
     self['leechers'] = leechers
     self['total_leechers'] = total_leechers
     self['peers'] = peers
     self['total_peers'] = total_peers
     self['priority'] = priority
     self['private'] = private
     self['is_active'] = is_active
     self['progress'] = util.fmt_ratio(progress)
コード例 #4
0
ファイル: app.py プロジェクト: kannibalox/tranny
 def human_size(value):
     return file_size(value)
コード例 #5
0
 def human_size(value):
     return file_size(value)