summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/addons/ExtractArchive.py
diff options
context:
space:
mode:
authorGravatar Stefano <l.stickell@yahoo.it> 2013-07-24 14:24:51 +0200
committerGravatar Stefano <l.stickell@yahoo.it> 2013-07-24 14:36:59 +0200
commit9be1035b2945f82b269487a009c02bd5a83028b0 (patch)
tree83c2496c60ddb5de3821151b80d69b639f007fe3 /pyload/plugins/addons/ExtractArchive.py
parentTwo more replace module import rules (diff)
downloadpyload-9be1035b2945f82b269487a009c02bd5a83028b0.tar.xz
Fixed PEP 8 violations in Hooks
(cherry picked from commit 669b1e0ec048e1ed8aeb842b2570376e9ad96863) Conflicts: pyload/plugins/addons/CaptchaTrader.py pyload/plugins/addons/ClickAndLoad.py pyload/plugins/addons/Ev0InFetcher.py pyload/plugins/addons/ExternalScripts.py pyload/plugins/addons/ExtractArchive.py pyload/plugins/addons/HotFolder.py pyload/plugins/addons/MergeFiles.py pyload/plugins/addons/MultiHome.py pyload/plugins/addons/XMPPInterface.py
Diffstat (limited to 'pyload/plugins/addons/ExtractArchive.py')
-rw-r--r--pyload/plugins/addons/ExtractArchive.py58
1 files changed, 31 insertions, 27 deletions
diff --git a/pyload/plugins/addons/ExtractArchive.py b/pyload/plugins/addons/ExtractArchive.py
index d5609863e..91f1f96c5 100644
--- a/pyload/plugins/addons/ExtractArchive.py
+++ b/pyload/plugins/addons/ExtractArchive.py
@@ -52,6 +52,7 @@ from module.utils.fs import save_join, fs_encode, exists, remove, chmod, makedir
from module.plugins.Addon import Addon, threaded, Expose
from module.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword
+
class ExtractArchive(Addon):
"""
Provides: unrarFinished (folder, filename)
@@ -60,15 +61,15 @@ class ExtractArchive(Addon):
__version__ = "0.14"
__description__ = "Extract different kind of archives"
__config__ = [("activated", "bool", "Activated", True),
- ("fullpath", "bool", "Extract full path", True),
- ("overwrite", "bool", "Overwrite files", True),
- ("passwordfile", "file", "password file", "unrar_passwords.txt"),
- ("deletearchive", "bool", "Delete archives when done", False),
- ("subfolder", "bool", "Create subfolder for each package", False),
- ("destination", "folder", "Extract files to", ""),
- ("recursive", "bool", "Extract archives in archvies", True),
- ("queue", "bool", "Wait for all downloads to be finished", True),
- ("renice", "int", "CPU Priority", 0), ]
+ ("fullpath", "bool", "Extract full path", True),
+ ("overwrite", "bool", "Overwrite files", True),
+ ("passwordfile", "file", "password file", "unrar_passwords.txt"),
+ ("deletearchive", "bool", "Delete archives when done", False),
+ ("subfolder", "bool", "Create subfolder for each package", False),
+ ("destination", "folder", "Extract files to", ""),
+ ("recursive", "bool", "Extract archives in archvies", True),
+ ("queue", "bool", "Wait for all downloads to be finished", True),
+ ("renice", "int", "CPU Priority", 0)]
__author_name__ = ("pyload Team")
__author_mail__ = ("admin<at>pyload.org")
@@ -120,14 +121,12 @@ class ExtractArchive(Addon):
else:
self.manager.startThread(self.extract, [pypack.id])
-
@threaded
def allDownloadsProcessed(self, thread):
local = copy(self.queue)
del self.queue[:]
self.extract(local, thread)
-
def extract(self, ids, thread=None):
# reload from txt file
self.reloadPasswords()
@@ -141,7 +140,8 @@ class ExtractArchive(Addon):
for pid in ids:
p = self.core.files.getPackage(pid)
self.logInfo(_("Check package %s") % p.name)
- if not p: continue
+ if not p:
+ continue
# determine output folder
out = save_join(dl, p.folder, "")
@@ -174,10 +174,10 @@ class ExtractArchive(Addon):
if target in extracted:
self.logDebug(basename(target), "skipped")
continue
- extracted.append(target) #prevent extracting same file twice
+ extracted.append(target) # prevent extracting same file twice
klass = plugin(self, target, out, self.getConfig("fullpath"), self.getConfig("overwrite"),
- self.getConfig("renice"))
+ self.getConfig("renice"))
klass.init()
self.logInfo(basename(target), _("Extract to %s") % out)
@@ -190,18 +190,20 @@ class ExtractArchive(Addon):
self.logDebug("new file %s does not exists" % file)
continue
if self.getConfig("recursive") and isfile(file):
- new_files_ids.append((file, fid)) #append as new target
+ new_files_ids.append((file, fid)) # append as new target
- files_ids = new_files_ids # also check extracted files
+ files_ids = new_files_ids # also check extracted files
- if not matched: self.logInfo(_("No files found to extract"))
+ if not matched:
+ self.logInfo(_("No files found to extract"))
def startExtracting(self, plugin, fid, passwords, thread):
pyfile = self.core.files.getFile(fid)
- if not pyfile: return []
+ if not pyfile:
+ return []
pyfile.setCustomStatus(_("extracting"))
- thread.addActive(pyfile) #keep this file until everything is done
+ thread.addActive(pyfile) # keep this file until everything is done
try:
progress = lambda x: pyfile.setProgress(x)
@@ -217,7 +219,8 @@ class ExtractArchive(Addon):
pwlist = copy(self.getPasswords())
#remove already supplied pws from list (only local)
for pw in passwords:
- if pw in pwlist: pwlist.remove(pw)
+ if pw in pwlist:
+ pwlist.remove(pw)
for pw in passwords + pwlist:
try:
@@ -241,15 +244,16 @@ class ExtractArchive(Addon):
files = plugin.getDeleteFiles()
self.logInfo(_("Deleting %s files") % len(files))
for f in files:
- if exists(f): remove(f)
- else: self.logDebug("%s does not exists" % f)
+ if exists(f):
+ remove(f)
+ else:
+ self.logDebug("%s does not exists" % f)
self.logInfo(basename(plugin.file), _("Extracting finished"))
self.manager.dispatchEvent("unrarFinished", plugin.out, plugin.file)
return plugin.getExtractedFiles()
-
except ArchiveError, e:
self.logError(basename(plugin.file), _("Archive Error"), str(e))
except CRCError:
@@ -266,7 +270,6 @@ class ExtractArchive(Addon):
""" List of saved passwords """
return self.passwords
-
def reloadPasswords(self):
pwfile = self.getConfig("passwordfile")
if not exists(pwfile):
@@ -280,13 +283,13 @@ class ExtractArchive(Addon):
self.passwords = passwords
-
@Expose
def addPassword(self, pw):
""" Adds a password to saved list"""
pwfile = self.getConfig("passwordfile")
- if pw in self.passwords: self.passwords.remove(pw)
+ if pw in self.passwords:
+ self.passwords.remove(pw)
self.passwords.insert(0, pw)
f = open(pwfile, "wb")
@@ -296,7 +299,8 @@ class ExtractArchive(Addon):
def setPermissions(self, files):
for f in files:
- if not exists(f): continue
+ if not exists(f):
+ continue
try:
if self.core.config["permission"]["change_file"]:
if isfile(f):