Fix displaying file percentages properly.

This commit is contained in:
Andrew Resch 2008-07-14 23:17:20 +00:00
parent a2b2b4c3f4
commit 31bb4eface
1 changed files with 10 additions and 1 deletions

View File

@ -365,7 +365,16 @@ class Torrent:
def get_queue_position(self):
"""Returns the torrents queue position"""
return self.handle.queue_position()
def get_file_progress(self):
"""Returns the file progress as a list of floats.. 0.0 -> 1.0"""
file_progress = self.handle.file_progress()
ret = []
for i,f in enumerate(self.files):
ret.append(file_progress[i] / f["size"])
return ret
def get_status(self, keys):
"""Returns the status of the torrent based on the keys provided"""
# Create the full dictionary
@ -429,7 +438,7 @@ class Torrent:
"piece_length": self.torrent_info.piece_length,
"eta": self.get_eta,
"ratio": self.get_ratio,
"file_progress": self.handle.file_progress,
"file_progress": self.get_file_progress,
"queue": self.handle.queue_position,
"is_seed": self.handle.is_seed,
"peers": self.get_peers,