flake8'd torrent.py

This commit is contained in:
Calum Lind 2014-01-18 22:14:14 +00:00
parent 7624683710
commit 58e9f66d64
1 changed files with 67 additions and 67 deletions

View File

@ -46,7 +46,7 @@ from deluge._libtorrent import lt
import deluge.common
import deluge.component as component
from deluge.configmanager import ConfigManager, get_config_dir
from deluge.event import *
from deluge.event import TorrentStateChangedEvent, TorrentFolderRenamedEvent
from deluge.common import decode_string
TORRENT_STATE = deluge.common.TORRENT_STATE
@ -685,76 +685,76 @@ class Torrent(object):
def _create_status_funcs(self):
self.status_funcs = {
"active_time": lambda: self.status.active_time,
"all_time_download": lambda: self.status.all_time_download,
"compact": lambda: self.options["compact_allocation"],
"distributed_copies": lambda: 0.0 if self.status.distributed_copies < 0 else
"active_time": lambda: self.status.active_time,
"all_time_download": lambda: self.status.all_time_download,
"compact": lambda: self.options["compact_allocation"],
"distributed_copies": lambda: 0.0 if self.status.distributed_copies < 0 else
self.status.distributed_copies, # Adjust status.distributed_copies to return a non-negative value
"download_payload_rate": lambda: self.status.download_payload_rate,
"file_priorities": lambda: self.options["file_priorities"],
"hash": lambda: self.torrent_id,
"is_auto_managed": lambda: self.options["auto_managed"],
"is_finished": lambda: self.is_finished,
"max_connections": lambda: self.options["max_connections"],
"max_download_speed": lambda: self.options["max_download_speed"],
"max_upload_slots": lambda: self.options["max_upload_slots"],
"max_upload_speed": lambda: self.options["max_upload_speed"],
"message": lambda: self.statusmsg,
"download_payload_rate": lambda: self.status.download_payload_rate,
"file_priorities": lambda: self.options["file_priorities"],
"hash": lambda: self.torrent_id,
"is_auto_managed": lambda: self.options["auto_managed"],
"is_finished": lambda: self.is_finished,
"max_connections": lambda: self.options["max_connections"],
"max_download_speed": lambda: self.options["max_download_speed"],
"max_upload_slots": lambda: self.options["max_upload_slots"],
"max_upload_speed": lambda: self.options["max_upload_speed"],
"message": lambda: self.statusmsg,
"move_on_completed_path": lambda: self.options["move_completed_path"],
"move_on_completed": lambda: self.options["move_completed"],
"move_completed_path": lambda: self.options["move_completed_path"],
"move_completed": lambda: self.options["move_completed"],
"next_announce": lambda: self.status.next_announce.seconds,
"num_peers": lambda: self.status.num_peers - self.status.num_seeds,
"num_seeds": lambda: self.status.num_seeds,
"owner": lambda: self.owner,
"paused": lambda: self.status.paused,
"prioritize_first_last": lambda: self.options["prioritize_first_last_pieces"],
"sequential_download": lambda: self.options["sequential_download"],
"progress": lambda: self.status.progress * 100,
"shared": lambda: self.options["shared"],
"remove_at_ratio": lambda: self.options["remove_at_ratio"],
"save_path": lambda: self.options["download_location"],
"seeding_time": lambda: self.status.seeding_time,
"seeds_peers_ratio": lambda: -1.0 if self.status.num_incomplete == 0 else
"move_on_completed": lambda: self.options["move_completed"],
"move_completed_path": lambda: self.options["move_completed_path"],
"move_completed": lambda: self.options["move_completed"],
"next_announce": lambda: self.status.next_announce.seconds,
"num_peers": lambda: self.status.num_peers - self.status.num_seeds,
"num_seeds": lambda: self.status.num_seeds,
"owner": lambda: self.owner,
"paused": lambda: self.status.paused,
"prioritize_first_last": lambda: self.options["prioritize_first_last_pieces"],
"sequential_download": lambda: self.options["sequential_download"],
"progress": lambda: self.status.progress * 100,
"shared": lambda: self.options["shared"],
"remove_at_ratio": lambda: self.options["remove_at_ratio"],
"save_path": lambda: self.options["download_location"],
"seeding_time": lambda: self.status.seeding_time,
"seeds_peers_ratio": lambda: -1.0 if self.status.num_incomplete == 0 else
self.status.num_complete / float(self.status.num_incomplete), # Use -1.0 to signify infinity
"seed_rank": lambda: self.status.seed_rank,
"state": lambda: self.state,
"stop_at_ratio": lambda: self.options["stop_at_ratio"],
"stop_ratio": lambda: self.options["stop_ratio"],
"time_added": lambda: self.status.added_time,
"total_done": lambda: self.status.total_done,
"seed_rank": lambda: self.status.seed_rank,
"state": lambda: self.state,
"stop_at_ratio": lambda: self.options["stop_at_ratio"],
"stop_ratio": lambda: self.options["stop_ratio"],
"time_added": lambda: self.status.added_time,
"total_done": lambda: self.status.total_done,
"total_payload_download": lambda: self.status.total_payload_download,
"total_payload_upload": lambda: self.status.total_payload_upload,
"total_peers": lambda: self.status.num_incomplete,
"total_seeds": lambda: self.status.num_complete,
"total_uploaded": lambda: self.status.all_time_upload,
"total_wanted": lambda: self.status.total_wanted,
"total_remaining": lambda: self.status.total_wanted - self.status.total_wanted_done,
"tracker": lambda: self.status.current_tracker,
"trackers": lambda: self.trackers,
"tracker_status": lambda: self.tracker_status,
"upload_payload_rate": lambda: self.status.upload_payload_rate,
"comment": lambda: decode_string(self.torrent_info.comment()) if self.has_metadata else u"",
"num_files": lambda: self.torrent_info.num_files() if self.has_metadata else 0,
"num_pieces": lambda: self.torrent_info.num_pieces() if self.has_metadata else 0,
"piece_length": lambda: self.torrent_info.piece_length() if self.has_metadata else 0,
"private": lambda: self.torrent_info.priv() if self.has_metadata else False,
"total_size": lambda: self.torrent_info.total_size() if self.has_metadata else 0,
"eta": self.get_eta,
"file_progress": self.get_file_progress, # Adjust progress to be 0-100 value
"files": self.get_files,
"is_seed": lambda: self.status.is_seeding,
"peers": self.get_peers,
"queue": lambda: self.status.queue_position,
"ratio": self.get_ratio,
"tracker_host": self.get_tracker_host,
"completed_time": lambda: self.status.completed_time,
"last_seen_complete": lambda: self.status.last_seen_complete,
"name": self.get_name,
"pieces": self._get_pieces_info,
"seed_mode": lambda: self.status.seed_mode,
"super_seeding": lambda: self.status.super_seeding,
"total_payload_upload": lambda: self.status.total_payload_upload,
"total_peers": lambda: self.status.num_incomplete,
"total_seeds": lambda: self.status.num_complete,
"total_uploaded": lambda: self.status.all_time_upload,
"total_wanted": lambda: self.status.total_wanted,
"total_remaining": lambda: self.status.total_wanted - self.status.total_wanted_done,
"tracker": lambda: self.status.current_tracker,
"trackers": lambda: self.trackers,
"tracker_status": lambda: self.tracker_status,
"upload_payload_rate": lambda: self.status.upload_payload_rate,
"comment": lambda: decode_string(self.torrent_info.comment()) if self.has_metadata else u"",
"num_files": lambda: self.torrent_info.num_files() if self.has_metadata else 0,
"num_pieces": lambda: self.torrent_info.num_pieces() if self.has_metadata else 0,
"piece_length": lambda: self.torrent_info.piece_length() if self.has_metadata else 0,
"private": lambda: self.torrent_info.priv() if self.has_metadata else False,
"total_size": lambda: self.torrent_info.total_size() if self.has_metadata else 0,
"eta": self.get_eta,
"file_progress": self.get_file_progress, # Adjust progress to be 0-100 value
"files": self.get_files,
"is_seed": lambda: self.status.is_seeding,
"peers": self.get_peers,
"queue": lambda: self.status.queue_position,
"ratio": self.get_ratio,
"tracker_host": self.get_tracker_host,
"completed_time": lambda: self.status.completed_time,
"last_seen_complete": lambda: self.status.last_seen_complete,
"name": self.get_name,
"pieces": self._get_pieces_info,
"seed_mode": lambda: self.status.seed_mode,
"super_seeding": lambda: self.status.super_seeding,
}
def get_name(self):