summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/UnRar.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2013-11-17 19:29:37 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2013-11-23 17:39:12 +0100
commit92888358e14c0a9e50e5604095a1c148ccc8b80d (patch)
tree2c3f5b0c141ac90e34e2c8360886bc14f9715edd /module/plugins/internal/UnRar.py
parentMerge pull request #386 from vuolter/s/setup_clean (diff)
downloadpyload-92888358e14c0a9e50e5604095a1c148ccc8b80d.tar.xz
Internal plugins PEP8 cleanup
Diffstat (limited to 'module/plugins/internal/UnRar.py')
-rw-r--r--module/plugins/internal/UnRar.py38
1 files changed, 18 insertions, 20 deletions
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index 80ee39cdf..ec430c5bc 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
-
+
@author: RaNaN
"""
@@ -27,6 +27,7 @@ from string import digits
from module.utils import save_join, decode
from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError, CRCError
+
class UnRar(AbtractExtractor):
__name__ = "UnRar"
__version__ = "0.14"
@@ -50,7 +51,7 @@ class UnRar(AbtractExtractor):
p.communicate()
except OSError:
- #fallback to rar
+ # fallback to rar
UnRar.CMD = "rar"
p = Popen([UnRar.CMD], stdout=PIPE, stderr=PIPE)
p.communicate()
@@ -62,11 +63,12 @@ class UnRar(AbtractExtractor):
result = []
for file, id in files_ids:
- if not file.endswith(".rar"): continue
+ if not file.endswith(".rar"):
+ continue
match = UnRar.re_splitfile.findall(file)
if match:
- #only add first parts
+ # only add first parts
if int(match[0][1]) == 1:
result.append((file, id))
else:
@@ -74,12 +76,11 @@ class UnRar(AbtractExtractor):
return result
-
def init(self):
self.passwordProtected = False
- self.headerProtected = False #list files will not work without password
- self.smallestFile = None #small file to test passwords
- self.password = "" #save the correct password
+ self.headerProtected = False #: list files will not work without password
+ self.smallestFile = None #: small file to test passwords
+ self.password = "" #: save the correct password
def checkArchive(self):
p = self.call_unrar("l", "-v", self.file)
@@ -102,7 +103,7 @@ class UnRar(AbtractExtractor):
return False
def checkPassword(self, password):
- #at this point we can only verify header protected files
+ # at this point we can only verify header protected files
if self.headerProtected:
p = self.call_unrar("l", "-v", self.file, password=password)
out, err = p.communicate()
@@ -111,7 +112,6 @@ class UnRar(AbtractExtractor):
return True
-
def extract(self, progress, password=None):
command = "x" if self.fullpath else "e"
@@ -144,7 +144,7 @@ class UnRar(AbtractExtractor):
raise CRCError
elif "CRC failed" in err:
raise WrongPassword
- if err.strip(): #raise error if anything is on stderr
+ if err.strip(): #: raise error if anything is on stderr
raise ArchiveError(err.strip())
if p.returncode:
raise ArchiveError("Process terminated")
@@ -153,7 +153,6 @@ class UnRar(AbtractExtractor):
self.password = password
self.listContent()
-
def getDeleteFiles(self):
if ".part" in self.file:
return glob(re.sub("(?<=\.part)([01]+)", "*", self.file, re.IGNORECASE))
@@ -169,7 +168,7 @@ class UnRar(AbtractExtractor):
if "Cannot open" in err:
raise ArchiveError("Cannot open file")
- if err.strip(): # only log error at this point
+ if err.strip(): #: only log error at this point
self.m.logError(err.strip())
result = set()
@@ -180,26 +179,25 @@ class UnRar(AbtractExtractor):
self.files = result
-
def call_unrar(self, command, *xargs, **kwargs):
args = []
- #overwrite flag
+ # overwrite flag
args.append("-o+") if self.overwrite else args.append("-o-")
-
+
if self.excludefiles:
for word in self.excludefiles.split(';'):
- args.append("-x%s" % word )
-
+ args.append("-x%s" % word)
+
# assume yes on all queries
args.append("-y")
- #set a password
+ # set a password
if "password" in kwargs and kwargs["password"]:
args.append("-p%s" % kwargs["password"])
else:
args.append("-p-")
- #NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue
+ # NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue
call = [self.CMD, command] + args + list(xargs)
self.m.logDebug(" ".join(call))