From db5b5a9c4e00403e750efbd667bf97ef65ad4510 Mon Sep 17 00:00:00 2001 From: qstokkink Date: Tue, 13 Mar 2018 13:50:18 +0100 Subject: [PATCH] Fixed AllChannel2.0 pylint issues --- .../Community/Allchannel2/test_structures.py | 2 +- Tribler/community/allchannel2/community.py | 2 +- Tribler/community/allchannel2/payload.py | 4 ++-- Tribler/community/allchannel2/structures.py | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tribler/Test/Community/Allchannel2/test_structures.py b/Tribler/Test/Community/Allchannel2/test_structures.py index 73eed5d5586..a716a726f7d 100644 --- a/Tribler/Test/Community/Allchannel2/test_structures.py +++ b/Tribler/Test/Community/Allchannel2/test_structures.py @@ -1,6 +1,6 @@ import unittest -from Tribler.community.allchannel2.structures import Channel, Chunk, ChunkedTable +from Tribler.community.allchannel2.structures import Chunk, ChunkedTable class TestChunk(unittest.TestCase): diff --git a/Tribler/community/allchannel2/community.py b/Tribler/community/allchannel2/community.py index d9256af4eae..96497a689eb 100644 --- a/Tribler/community/allchannel2/community.py +++ b/Tribler/community/allchannel2/community.py @@ -74,7 +74,7 @@ def load_channel(self, channel): """ real_path = os.path.abspath(os.path.join(self.working_directory, channel)) if os.path.isdir(real_path): - channel_instance = Channel(channel, self.working_directory, allow_edit=(channel==self.my_channel_name)) + channel_instance = Channel(channel, self.working_directory, allow_edit=(channel == self.my_channel_name)) channel_instance.load() self.channels[channel] = channel_instance diff --git a/Tribler/community/allchannel2/payload.py b/Tribler/community/allchannel2/payload.py index 05dd8155ba1..754d5232981 100644 --- a/Tribler/community/allchannel2/payload.py +++ b/Tribler/community/allchannel2/payload.py @@ -12,5 +12,5 @@ def to_pack_list(self): return [('20s', self.info_hash)] @classmethod - def from_unpack_list(cls, info_hash): - return cls(info_hash) + def from_unpack_list(cls, *args): + return cls(*args) diff --git a/Tribler/community/allchannel2/structures.py b/Tribler/community/allchannel2/structures.py index cdf057292ec..84d4222f713 100644 --- a/Tribler/community/allchannel2/structures.py +++ b/Tribler/community/allchannel2/structures.py @@ -1,7 +1,6 @@ import os -from libtorrent import (add_files, bdecode, bencode, create_torrent, create_torrent_flags_t, - file_storage, set_piece_hashes) +from libtorrent import add_files, bdecode, bencode, create_torrent, file_storage, set_piece_hashes PIECE_SIZE = 16*1024*1024 # 16 MB: Holds 762600 magnetlinks without metadata @@ -144,16 +143,16 @@ def serialize(self): return out @classmethod - def unserialize(cls, map): + def unserialize(cls, mapping): """ Read in a ChunkedTable from a map of filenames to file contents. - :param map: the serialized Chunkforms per chunk id + :param mapping: the serialized Chunkforms per chunk id :returns: the ChunkedTable corresponding to the input map """ chunk_table = ChunkedTable() - for i in map.keys(): - chunk_table.chunklist[int(i)] = Chunk.unserialize(map[i]) + for i in mapping.keys(): + chunk_table.chunklist[int(i)] = Chunk.unserialize(mapping[i]) return chunk_table def get_all(self): @@ -181,6 +180,7 @@ def __init__(self, name, directory=".", allow_edit=False): super(Channel, self).__init__() self.name = name + self.allow_edit = allow_edit self.channel_directory = os.path.abspath(os.path.join(directory, name)) if not os.path.isdir(self.channel_directory): os.makedirs(self.channel_directory) @@ -206,8 +206,8 @@ def remove_magnetlink(self, magnetlink): """ self.chunked_table.remove(magnetlink) to_remove = set(os.listdir(self.channel_directory)) - set(self.chunked_table.chunklist.keys()) - for file in to_remove: - real_file = os.path.abspath(os.path.join(self.channel_directory, file)) + for filename in to_remove: + real_file = os.path.abspath(os.path.join(self.channel_directory, filename)) os.remove(real_file) def get_magnetlinks(self):