some small fix..

This commit is contained in:
ppwwyyxx
2015-05-25 15:17:17 +08:00
parent c6044221d7
commit f399643bb9
3 changed files with 10 additions and 5 deletions
+3 -2
View File
@@ -1,10 +1,11 @@
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: dump_msg.py
# Date: Wed Mar 25 17:44:34 2015 +0800
# Date: Mon May 25 15:16:31 2015 +0800
# Author: Yuxin Wu <[email protected]>
from wechat.parser import WeChatDBParser
from wechat.utils import safe_filename
import sys, os
if len(sys.argv) != 3:
@@ -23,6 +24,6 @@ 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, name + '.txt'), 'w') as f:
with open(os.path.join(output_dir, safe_filename(name) + '.txt'), 'w') as f:
for m in msgs:
print >> f, m
+2 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: msg.py
# Date: Wed Mar 25 22:27:58 2015 +0800
# Date: Wed May 06 10:47:57 2015 +0800
# Author: Yuxin Wu <[email protected]>
TYPE_MSG = 1
TYPE_IMG = 3
@@ -83,7 +83,7 @@ class WeChatMsg(object):
name = msg['alias']
if not name:
name = ""
return u"NAMECARD: {}".format(name)
return u"NAMECARD: {}".format(self.content_xml_ready)
elif self.type == TYPE_APP_MSG:
pq = PyQuery(self.content_xml_ready, parser='xml')
return pq('title').text()
+5 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: utils.py
# Date: Sun Jan 11 23:38:16 2015 +0800
# Date: Mon May 25 15:16:14 2015 +0800
# Author: Yuxin Wu <[email protected]>
import sys
@@ -167,3 +167,7 @@ def md5(s):
def get_file_b64(fname):
data = open(fname, 'rb').read()
return base64.b64encode(data)
def safe_filename(fname):
return "".join(
[c for c in filename if c.isalpha() or c.isdigit() or c==' ']).rstrip()