Better support of badly encoded names

pull/9/head
Raphaël Vinot 2016-05-09 18:32:45 +02:00
parent 7b71eba4a0
commit f69ac5ae2e
1 changed files with 7 additions and 7 deletions

View File

@ -159,7 +159,7 @@ class KittenGroomerBase(object):
def _computehash(self, path):
s = hashlib.sha1()
with open(path, 'rb') as f:
with open(path, 'rb', errors='surrogateescape') as f:
while True:
buf = f.read(0x100000)
if not buf:
@ -168,7 +168,7 @@ class KittenGroomerBase(object):
return s.hexdigest()
def tree(self, base_dir, padding=' '):
with open(self.log_content, 'a') as lf:
with open(self.log_content, 'a', errors='surrogateescape') as lf:
lf.write('#' * 80 + '\n')
lf.write('{}+- {}/\n'.format(padding, os.path.basename(os.path.abspath(base_dir))))
padding += '| '
@ -220,8 +220,8 @@ class KittenGroomerBase(object):
try:
if os.path.exists(self.cur_file.src_path + ext):
raise KittenGroomerError("Cannot create split metadata file for \"" +
self.cur_file.dst_path + "\", type '"
+ ext + "': File exists.")
self.cur_file.dst_path + "\", type '" +
ext + "': File exists.")
dst_path, filename = os.path.split(dst)
self._safe_mkdir(dst_path)
return open(dst + ext, 'w+')