From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/hooks/MergeFiles.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/MergeFiles.py') diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 99b0aafc6..e7bd63d17 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: and9000 """ import os @@ -23,7 +21,7 @@ import traceback from os.path import join from module.utils import save_join, fs_encode -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded BUFFER_SIZE = 4096 @@ -31,16 +29,20 @@ BUFFER_SIZE = 4096 class MergeFiles(Hook): __name__ = "MergeFiles" __version__ = "0.12" - __description__ = """Merges parts splitted with hjsplit""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False)] - __threaded__ = ["packageFinished"] + + __description__ = """Merges parts splitted with hjsplit""" __author_name__ = "and9000" __author_mail__ = "me@has-no-mail.com" + def setup(self): # nothing to do pass + @threaded def packageFinished(self, pack): files = {} fid_dict = {} -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/hooks/MergeFiles.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/hooks/MergeFiles.py') diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index e7bd63d17..5d6c208a7 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -47,12 +47,12 @@ class MergeFiles(Hook): files = {} fid_dict = {} for fid, data in pack.getChildren().iteritems(): - if re.search("\.[0-9]{3}$", data["name"]): - if data["name"][:-4] not in files: - files[data["name"][:-4]] = [] - files[data["name"][:-4]].append(data["name"]) - files[data["name"][:-4]].sort() - fid_dict[data["name"]] = fid + if re.search("\.[0-9]{3}$", data['name']): + if data['name'][:-4] not in files: + files[data['name'][:-4]] = [] + files[data['name'][:-4]].append(data['name']) + files[data['name'][:-4]].sort() + fid_dict[data['name']] = fid download_folder = self.config['general']['download_folder'] -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hooks/MergeFiles.py | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'module/plugins/hooks/MergeFiles.py') diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 5d6c208a7..a859092fb 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -1,35 +1,17 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" - import os import re import traceback -from os.path import join -from module.utils import save_join, fs_encode from module.plugins.Hook import Hook, threaded - -BUFFER_SIZE = 4096 +from module.utils import save_join, fs_encode class MergeFiles(Hook): __name__ = "MergeFiles" - __version__ = "0.12" __type__ = "hook" + __version__ = "0.12" __config__ = [("activated", "bool", "Activated", False)] @@ -37,6 +19,8 @@ class MergeFiles(Hook): __author_name__ = "and9000" __author_mail__ = "me@has-no-mail.com" + BUFFER_SIZE = 4096 + def setup(self): # nothing to do @@ -61,7 +45,7 @@ class MergeFiles(Hook): for name, file_list in files.iteritems(): self.logInfo("Starting merging of %s" % name) - final_file = open(join(download_folder, fs_encode(name)), "wb") + final_file = open(save_join(download_folder, name), "wb") for splitted_file in file_list: self.logDebug("Merging part %s" % splitted_file) @@ -72,10 +56,10 @@ class MergeFiles(Hook): size_written = 0 s_file_size = int(os.path.getsize(os.path.join(download_folder, splitted_file))) while True: - f_buffer = s_file.read(BUFFER_SIZE) + f_buffer = s_file.read(self.BUFFER_SIZE) if f_buffer: final_file.write(f_buffer) - size_written += BUFFER_SIZE + size_written += self.BUFFER_SIZE pyfile.setProgress((size_written * 100) / s_file_size) else: break -- cgit v1.2.3