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):
|
def _computehash(self, path):
|
||||||
s = hashlib.sha1()
|
s = hashlib.sha1()
|
||||||
with open(path, 'rb') as f:
|
with open(path, 'rb', errors='surrogateescape') as f:
|
||||||
while True:
|
while True:
|
||||||
buf = f.read(0x100000)
|
buf = f.read(0x100000)
|
||||||
if not buf:
|
if not buf:
|
||||||
|
@ -168,7 +168,7 @@ class KittenGroomerBase(object):
|
||||||
return s.hexdigest()
|
return s.hexdigest()
|
||||||
|
|
||||||
def tree(self, base_dir, padding=' '):
|
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('#' * 80 + '\n')
|
||||||
lf.write('{}+- {}/\n'.format(padding, os.path.basename(os.path.abspath(base_dir))))
|
lf.write('{}+- {}/\n'.format(padding, os.path.basename(os.path.abspath(base_dir))))
|
||||||
padding += '| '
|
padding += '| '
|
||||||
|
@ -218,13 +218,13 @@ class KittenGroomerBase(object):
|
||||||
'''Create a separate file to hold this file's metadata'''
|
'''Create a separate file to hold this file's metadata'''
|
||||||
dst = self.cur_file.dst_path
|
dst = self.cur_file.dst_path
|
||||||
try:
|
try:
|
||||||
if os.path.exists(self.cur_file.src_path+ext):
|
if os.path.exists(self.cur_file.src_path + ext):
|
||||||
raise KittenGroomerError("Cannot create split metadata file for \"" +
|
raise KittenGroomerError("Cannot create split metadata file for \"" +
|
||||||
self.cur_file.dst_path + "\", type '"
|
self.cur_file.dst_path + "\", type '" +
|
||||||
+ ext + "': File exists.")
|
ext + "': File exists.")
|
||||||
dst_path, filename = os.path.split(dst)
|
dst_path, filename = os.path.split(dst)
|
||||||
self._safe_mkdir(dst_path)
|
self._safe_mkdir(dst_path)
|
||||||
return open(dst+ext, 'w+')
|
return open(dst + ext, 'w+')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO: Logfile
|
# TODO: Logfile
|
||||||
print(e)
|
print(e)
|
||||||
|
|
Loading…
Reference in New Issue