mirror of https://github.com/CIRCL/PyCIRCLean
Better support of badly encoded names
parent
7b71eba4a0
commit
f69ac5ae2e
|
@ -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+')
|
||||
|
|
Loading…
Reference in New Issue