mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
Fix linting mistakes
Missed renaming file to _file. This commit now uses better naming with some minor refactoring.
This commit is contained in:
parent
f500d78487
commit
f1e70829af
2 changed files with 21 additions and 23 deletions
|
@ -168,9 +168,9 @@ class Command(BaseCommand):
|
||||||
cols = 80
|
cols = 80
|
||||||
|
|
||||||
prevpath = []
|
prevpath = []
|
||||||
for i, _file in enumerate(status["files"]):
|
for index, torrent_file in enumerate(status["files"]):
|
||||||
filename = _file["path"].split(dirsep)[-1]
|
filename = torrent_file["path"].split(dirsep)[-1]
|
||||||
filepath = _file["path"].split(dirsep)[:-1]
|
filepath = torrent_file["path"].split(dirsep)[:-1]
|
||||||
|
|
||||||
for depth, subdir in enumerate(filepath):
|
for depth, subdir in enumerate(filepath):
|
||||||
indent = " " * depth * spaces_per_level
|
indent = " " * depth * spaces_per_level
|
||||||
|
@ -184,20 +184,20 @@ class Command(BaseCommand):
|
||||||
indent = " " * depth * spaces_per_level
|
indent = " " * depth * spaces_per_level
|
||||||
|
|
||||||
col_filename = indent + filename
|
col_filename = indent + filename
|
||||||
col_size = " ({!cyan!}%s{!input!})" % common.fsize(file["size"])
|
col_size = " ({!cyan!}%s{!input!})" % common.fsize(torrent_file["size"])
|
||||||
col_progress = " {!input!}%.2f%%" % (status["file_progress"][i] * 100)
|
col_progress = " {!input!}%.2f%%" % (status["file_progress"][index] * 100)
|
||||||
|
|
||||||
col_priority = " {!info!}Priority: "
|
col_priority = " {!info!}Priority: "
|
||||||
|
|
||||||
fp = common.FILE_PRIORITY[status["file_priorities"][i]].replace("Priority", "")
|
file_priority = common.FILE_PRIORITY[status["file_priorities"][index]].replace("Priority", "")
|
||||||
if status["file_progress"][i] != 1.0:
|
if status["file_progress"][index] != 1.0:
|
||||||
if fp == "Do Not Download":
|
if file_priority == "Do Not Download":
|
||||||
col_priority += "{!error!}"
|
col_priority += "{!error!}"
|
||||||
else:
|
else:
|
||||||
col_priority += "{!success!}"
|
col_priority += "{!success!}"
|
||||||
else:
|
else:
|
||||||
col_priority += "{!input!}"
|
col_priority += "{!input!}"
|
||||||
col_priority += fp
|
col_priority += file_priority
|
||||||
|
|
||||||
def tlen(string):
|
def tlen(string):
|
||||||
return strwidth(format_utils.remove_formatting(string))
|
return strwidth(format_utils.remove_formatting(string))
|
||||||
|
|
|
@ -343,39 +343,37 @@ class FilesTab(Tab):
|
||||||
show_file(filepath, timestamp=timestamp)
|
show_file(filepath, timestamp=timestamp)
|
||||||
|
|
||||||
# The following 3 methods create the folder/file view in the treeview
|
# The following 3 methods create the folder/file view in the treeview
|
||||||
def prepare_file_store(self, files):
|
def prepare_file_store(self, torrent_files):
|
||||||
split_files = {}
|
split_files = {}
|
||||||
i = 0
|
for index, torrent_file in enumerate(torrent_files):
|
||||||
for _file in files:
|
self.prepare_file(torrent_file, torrent_file["path"], index, split_files)
|
||||||
self.prepare_file(_file, _file["path"], i, split_files)
|
|
||||||
i += 1
|
|
||||||
self.add_files(None, split_files)
|
self.add_files(None, split_files)
|
||||||
|
|
||||||
def prepare_file(self, _file, file_name, file_num, files_storage):
|
def prepare_file(self, torrent_file, file_name, file_num, files_storage):
|
||||||
first_slash_index = file_name.find("/")
|
first_slash_index = file_name.find("/")
|
||||||
if first_slash_index == -1:
|
if first_slash_index == -1:
|
||||||
files_storage[file_name] = (file_num, _file)
|
files_storage[file_name] = (file_num, torrent_file)
|
||||||
else:
|
else:
|
||||||
file_name_chunk = file_name[:first_slash_index + 1]
|
file_name_chunk = file_name[:first_slash_index + 1]
|
||||||
if file_name_chunk not in files_storage:
|
if file_name_chunk not in files_storage:
|
||||||
files_storage[file_name_chunk] = {}
|
files_storage[file_name_chunk] = {}
|
||||||
self.prepare_file(file, file_name[first_slash_index + 1:],
|
self.prepare_file(torrent_file, file_name[first_slash_index + 1:],
|
||||||
file_num, files_storage[file_name_chunk])
|
file_num, files_storage[file_name_chunk])
|
||||||
|
|
||||||
def add_files(self, parent_iter, split_files):
|
def add_files(self, parent_iter, split_files):
|
||||||
ret = 0
|
chunk_size_total = 0
|
||||||
for key, value in split_files.iteritems():
|
for key, value in split_files.iteritems():
|
||||||
if key.endswith("/"):
|
if key.endswith("/"):
|
||||||
chunk_iter = self.treestore.append(parent_iter,
|
chunk_iter = self.treestore.append(parent_iter,
|
||||||
[key, 0, "", 0, 0, -1, gtk.STOCK_DIRECTORY])
|
[key, 0, "", 0, 0, -1, gtk.STOCK_DIRECTORY])
|
||||||
chunk_size = self.add_files(chunk_iter, value)
|
chunk_size = self.add_files(chunk_iter, value)
|
||||||
self.treestore.set(chunk_iter, 1, chunk_size)
|
self.treestore.set(chunk_iter, 1, chunk_size)
|
||||||
ret += chunk_size
|
chunk_size_total += chunk_size
|
||||||
else:
|
else:
|
||||||
self.treestore.append(parent_iter, [key,
|
self.treestore.append(parent_iter,
|
||||||
value[1]["size"], "", 0, 0, value[0], gtk.STOCK_FILE])
|
[key, value[1]["size"], "", 0, 0, value[0], gtk.STOCK_FILE])
|
||||||
ret += value[1]["size"]
|
chunk_size_total += value[1]["size"]
|
||||||
return ret
|
return chunk_size_total
|
||||||
|
|
||||||
def update_files(self):
|
def update_files(self):
|
||||||
with listview_replace_treestore(self.listview):
|
with listview_replace_treestore(self.listview):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue