diff --git a/dump_msg.py b/dump_msg.py index 4e5c49e..1a01a1d 100755 --- a/dump_msg.py +++ b/dump_msg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- coding: UTF-8 -*- # File: dump_msg.py -# Date: Mon May 25 15:16:31 2015 +0800 +# Date: Mon May 25 15:23:05 2015 +0800 # Author: Yuxin Wu from wechat.parser import WeChatDBParser @@ -24,6 +24,7 @@ parser = WeChatDBParser(db_file) for name, msgs in parser.msgs_by_talker.iteritems(): print u"Writing msgs for {}".format(name) - with open(os.path.join(output_dir, safe_filename(name) + '.txt'), 'w') as f: + safe_name = safe_filename(name) + with open(os.path.join(output_dir, safe_name + '.txt'), 'w') as f: for m in msgs: print >> f, m diff --git a/wechat/utils.py b/wechat/utils.py index 8cf7db9..e04572c 100644 --- a/wechat/utils.py +++ b/wechat/utils.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- coding: UTF-8 -*- # File: utils.py -# Date: Mon May 25 15:16:14 2015 +0800 +# Date: Mon May 25 15:21:06 2015 +0800 # Author: Yuxin Wu import sys @@ -169,5 +169,6 @@ def get_file_b64(fname): return base64.b64encode(data) def safe_filename(fname): + filename = ensure_unicode(fname) return "".join( [c for c in filename if c.isalpha() or c.isdigit() or c==' ']).rstrip()