Changeset f1e708


Ignore:
Timestamp:
11/03/2015 07:43:29 PM (10 years ago)
Author:
Calum Lind <calumlind+deluge@gmail.com>
Branches:
2.0.x, develop, master
Children:
05ab06
Parents:
f500d7
git-author:
Calum Lind <calumlind+deluge@gmail.com> (11/03/2015 07:29:50 PM)
git-committer:
Calum Lind <calumlind+deluge@gmail.com> (11/03/2015 07:43:29 PM)
Message:

Fix linting mistakes

Missed renaming file to _file. This commit now uses better naming with
some minor refactoring.

Location:
deluge/ui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • deluge/ui/console/commands/info.py

    rf500d7 rf1e708  
    169169
    170170        prevpath = []
    171         for i, _file in enumerate(status["files"]):
    172             filename = _file["path"].split(dirsep)[-1]
    173             filepath = _file["path"].split(dirsep)[:-1]
     171        for index, torrent_file in enumerate(status["files"]):
     172            filename = torrent_file["path"].split(dirsep)[-1]
     173            filepath = torrent_file["path"].split(dirsep)[:-1]
    174174
    175175            for depth, subdir in enumerate(filepath):
     
    185185
    186186            col_filename = indent + filename
    187             col_size = " ({!cyan!}%s{!input!})" % common.fsize(file["size"])
    188             col_progress = " {!input!}%.2f%%" % (status["file_progress"][i] * 100)
     187            col_size = " ({!cyan!}%s{!input!})" % common.fsize(torrent_file["size"])
     188            col_progress = " {!input!}%.2f%%" % (status["file_progress"][index] * 100)
    189189
    190190            col_priority = " {!info!}Priority: "
    191191
    192             fp = common.FILE_PRIORITY[status["file_priorities"][i]].replace("Priority", "")
    193             if status["file_progress"][i] != 1.0:
    194                 if fp == "Do Not Download":
     192            file_priority = common.FILE_PRIORITY[status["file_priorities"][index]].replace("Priority", "")
     193            if status["file_progress"][index] != 1.0:
     194                if file_priority == "Do Not Download":
    195195                    col_priority += "{!error!}"
    196196                else:
     
    198198            else:
    199199                col_priority += "{!input!}"
    200             col_priority += fp
     200            col_priority += file_priority
    201201
    202202            def tlen(string):
  • deluge/ui/gtkui/files_tab.py

    rf500d7 rf1e708  
    344344
    345345    # The following 3 methods create the folder/file view in the treeview
    346     def prepare_file_store(self, files):
     346    def prepare_file_store(self, torrent_files):
    347347        split_files = {}
    348         i = 0
    349         for _file in files:
    350             self.prepare_file(_file, _file["path"], i, split_files)
    351             i += 1
     348        for index, torrent_file in enumerate(torrent_files):
     349            self.prepare_file(torrent_file, torrent_file["path"], index, split_files)
    352350        self.add_files(None, split_files)
    353351
    354     def prepare_file(self, _file, file_name, file_num, files_storage):
     352    def prepare_file(self, torrent_file, file_name, file_num, files_storage):
    355353        first_slash_index = file_name.find("/")
    356354        if first_slash_index == -1:
    357             files_storage[file_name] = (file_num, _file)
     355            files_storage[file_name] = (file_num, torrent_file)
    358356        else:
    359357            file_name_chunk = file_name[:first_slash_index + 1]
    360358            if file_name_chunk not in files_storage:
    361359                files_storage[file_name_chunk] = {}
    362             self.prepare_file(file, file_name[first_slash_index + 1:],
     360            self.prepare_file(torrent_file, file_name[first_slash_index + 1:],
    363361                              file_num, files_storage[file_name_chunk])
    364362
    365363    def add_files(self, parent_iter, split_files):
    366         ret = 0
     364        chunk_size_total = 0
    367365        for key, value in split_files.iteritems():
    368366            if key.endswith("/"):
     
    371369                chunk_size = self.add_files(chunk_iter, value)
    372370                self.treestore.set(chunk_iter, 1, chunk_size)
    373                 ret += chunk_size
     371                chunk_size_total += chunk_size
    374372            else:
    375                 self.treestore.append(parent_iter, [key,
    376                                                     value[1]["size"], "", 0, 0, value[0], gtk.STOCK_FILE])
    377                 ret += value[1]["size"]
    378         return ret
     373                self.treestore.append(parent_iter,
     374                                      [key, value[1]["size"], "", 0, 0, value[0], gtk.STOCK_FILE])
     375                chunk_size_total += value[1]["size"]
     376        return chunk_size_total
    379377
    380378    def update_files(self):
Note: See TracChangeset for help on using the changeset viewer.