1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-15 18:56:28 +00:00

CBR/CB7: Unicode fix

This commit is contained in:
Paweł Jastrzębski
2013-10-10 19:52:49 +02:00
parent c5bcd4c2e4
commit c95c64ccff

View File

@@ -22,6 +22,7 @@ __docformat__ = 'restructuredtext en'
import os import os
import zipfile import zipfile
import rarfile import rarfile
import locale
from subprocess import Popen, STDOUT, PIPE from subprocess import Popen, STDOUT, PIPE
@@ -57,7 +58,7 @@ class CBxArchive:
cbzFile.extractall(targetdir, filelist) cbzFile.extractall(targetdir, filelist)
def extractCBR(self, targetdir): def extractCBR(self, targetdir):
cbrFile = rarfile.RarFile(self.origFileName) cbrFile = rarfile.RarFile(self.origFileName.encode(locale.getpreferredencoding()))
filelist = [] filelist = []
for f in cbrFile.namelist(): for f in cbrFile.namelist():
if f.startswith('__MACOSX') or f.endswith('.DS_Store') or f.endswith('thumbs.db'): if f.startswith('__MACOSX') or f.endswith('.DS_Store') or f.endswith('thumbs.db'):
@@ -68,12 +69,13 @@ class CBxArchive:
except: except:
pass # the dir exists so we are going to extract the images only. pass # the dir exists so we are going to extract the images only.
else: else:
filelist.append(f) filelist.append(f.encode(locale.getpreferredencoding()))
cbrFile.extractall(targetdir, filelist) cbrFile.extractall(targetdir, filelist)
def extractCB7(self, targetdir): def extractCB7(self, targetdir):
output = Popen('7za x "' + self.origFileName + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -o"' + targetdir + output = Popen('7za x "' + self.origFileName.encode(locale.getpreferredencoding()) +
'"', stdout=PIPE, stderr=STDOUT, shell=True) '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -o"' + targetdir + '"',
stdout=PIPE, stderr=STDOUT, shell=True)
extracted = False extracted = False
for line in output.stdout: for line in output.stdout:
if "Everything is Ok" in line: if "Everything is Ok" in line: