Skip to content

Commit

Permalink
Fixed AllChannel2.0 pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Mar 13, 2018
1 parent adf5f28 commit db5b5a9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Tribler/Test/Community/Allchannel2/test_structures.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion Tribler/community/allchannel2/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Tribler/community/allchannel2/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
16 changes: 8 additions & 8 deletions Tribler/community/allchannel2/structures.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit db5b5a9

Please sign in to comment.