From c95c64ccffd2ba7488a0255aa28dec8e988608a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 10 Oct 2013 19:52:49 +0200 Subject: [PATCH] CBR/CB7: Unicode fix --- kcc/cbxarchive.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kcc/cbxarchive.py b/kcc/cbxarchive.py index 226e77a..5d0e36f 100644 --- a/kcc/cbxarchive.py +++ b/kcc/cbxarchive.py @@ -22,6 +22,7 @@ __docformat__ = 'restructuredtext en' import os import zipfile import rarfile +import locale from subprocess import Popen, STDOUT, PIPE @@ -57,7 +58,7 @@ class CBxArchive: cbzFile.extractall(targetdir, filelist) def extractCBR(self, targetdir): - cbrFile = rarfile.RarFile(self.origFileName) + cbrFile = rarfile.RarFile(self.origFileName.encode(locale.getpreferredencoding())) filelist = [] for f in cbrFile.namelist(): if f.startswith('__MACOSX') or f.endswith('.DS_Store') or f.endswith('thumbs.db'): @@ -68,12 +69,13 @@ class CBxArchive: except: pass # the dir exists so we are going to extract the images only. else: - filelist.append(f) + filelist.append(f.encode(locale.getpreferredencoding())) cbrFile.extractall(targetdir, filelist) def extractCB7(self, targetdir): - output = Popen('7za x "' + self.origFileName + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -o"' + targetdir + - '"', stdout=PIPE, stderr=STDOUT, shell=True) + output = Popen('7za x "' + self.origFileName.encode(locale.getpreferredencoding()) + + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -o"' + targetdir + '"', + stdout=PIPE, stderr=STDOUT, shell=True) extracted = False for line in output.stdout: if "Everything is Ok" in line: