diff options
Diffstat (limited to 'deluge/metafile.py')
-rw-r--r-- | deluge/metafile.py | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/deluge/metafile.py b/deluge/metafile.py index 8784fe357..29c020e9f 100644 --- a/deluge/metafile.py +++ b/deluge/metafile.py @@ -50,13 +50,15 @@ class RemoteFileProgress(object): def __call__(self, piece_count, num_pieces): component.get('RPCServer').emit_event_for_session_id( - self.session_id, CreateTorrentProgressEvent(piece_count, num_pieces) + self.session_id, CreateTorrentProgressEvent(piece_count, num_pieces), ) -def make_meta_file(path, url, piece_length, progress=None, title=None, comment=None, - safe=None, content_type=None, target=None, webseeds=None, name=None, - private=False, created_by=None, trackers=None): +def make_meta_file( + path, url, piece_length, progress=None, title=None, comment=None, + safe=None, content_type=None, target=None, webseeds=None, name=None, + private=False, created_by=None, trackers=None, +): data = {'creation date': int(gmtime())} if url: data['announce'] = url.strip() @@ -147,8 +149,10 @@ def makeinfo(path, piece_length, progress, name=None, content_type=None, private size = os.path.getsize(f) p2 = [n.encode('utf8') for n in p] if content_type: - fs.append({'length': size, 'path': p2, - 'content_type': content_type}) # HEREDAVE. bad for batch! + fs.append({ + 'length': size, 'path': p2, + 'content_type': content_type, + }) # HEREDAVE. bad for batch! else: fs.append({'length': size, 'path': p2}) with open(f, 'rb') as file_: @@ -173,11 +177,13 @@ def makeinfo(path, piece_length, progress, name=None, content_type=None, private if not name: name = os.path.split(path)[1] - return {'pieces': b''.join(pieces), - 'piece length': piece_length, - 'files': fs, - 'name': name.encode('utf8'), - 'private': private} + return { + 'pieces': b''.join(pieces), + 'piece length': piece_length, + 'files': fs, + 'name': name.encode('utf8'), + 'private': private, + } else: size = os.path.getsize(path) if size >= piece_length: @@ -198,15 +204,19 @@ def makeinfo(path, piece_length, progress, name=None, content_type=None, private progress(piece_count, num_pieces) name = os.path.split(path)[1].encode('utf8') if content_type is not None: - return {'pieces': b''.join(pieces), - 'piece length': piece_length, 'length': size, - 'name': name, - 'content_type': content_type, - 'private': private} - return {'pieces': b''.join(pieces), + return { + 'pieces': b''.join(pieces), 'piece length': piece_length, 'length': size, 'name': name, - 'private': private} + 'content_type': content_type, + 'private': private, + } + return { + 'pieces': b''.join(pieces), + 'piece length': piece_length, 'length': size, + 'name': name, + 'private': private, + } def subfiles(d): |