Skip to content

Commit

Permalink
removed all instances of RTorrent.download_list
Browse files Browse the repository at this point in the history
replaced with list comprehension: [t.info_hash for t in RTorrent.torrents]
  • Loading branch information
cjlucas committed Apr 10, 2012
1 parent 23ecd66 commit 216e2d1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions rtorrent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def __init__(self, url, _verbose=False):
self.url = url #: From X{__init__(self, url)}
self._verbose = _verbose
self.torrents = [] #: List of L{Torrent} instances
self.download_list = [] #: List of torrent info hashes
self._rpc_methods = [] #: List of rTorrent RPC methods
self._torrent_cache = []

Expand Down Expand Up @@ -120,7 +119,6 @@ def get_torrents(self, view="main"):
@todo: add validity check for specified view
"""
self.torrents = []
self.download_list = []
methods = rtorrent.torrent.methods
retriever_methods = [m for m in methods \
if m.is_retriever() and m.is_available(self)]
Expand All @@ -137,7 +135,6 @@ def get_torrents(self, view="main"):
for m, r in zip(retriever_methods, result[1:]): # result[0] is the info_hash
results_dict[m.varname] = rtorrent.rpc.process_result(m, r)

self.download_list.append(result[0])
self.torrents.append(
Torrent(self, info_hash=result[0], **results_dict)
)
Expand Down Expand Up @@ -223,12 +220,12 @@ def load_torrent(self, torrent, start=False, verbose=False, verify_load=True):
i = 0
while i < MAX_RETRIES:
self.get_torrents()
if info_hash in self.download_list: break
if info_hash in [t.info_hash for t in self.torrents]: break

time.sleep(1) # was still getting AssertionErrors, delay should help
i += 1

assert info_hash in self.download_list, "Adding torrent was unsuccessful."
assert info_hash in [t.info_hash for t in self.torrents], "Adding torrent was unsuccessful."

return(find_torrent(info_hash, self.torrents))

Expand Down

0 comments on commit 216e2d1

Please sign in to comment.