add Res.py
This commit is contained in:
+6
-3
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: UTF-8 -*-
|
||||
# File: Parser.py
|
||||
# Date: Sat Nov 22 08:07:56 2014 +0800
|
||||
# Date: Sat Nov 22 20:48:04 2014 +0800
|
||||
# Author: Yuxin Wu <[email protected]>
|
||||
|
||||
import sqlite3
|
||||
@@ -9,6 +9,7 @@ from collections import defaultdict
|
||||
import itertools
|
||||
|
||||
from .Msg import WeChatMsg
|
||||
from .Res import Resource
|
||||
from .utils import ensure_unicode
|
||||
|
||||
""" tables in concern:
|
||||
@@ -22,7 +23,7 @@ rcontact
|
||||
"""
|
||||
|
||||
class WeChatDBParser(object):
|
||||
def __init__(self, db_fname):
|
||||
def __init__(self, db_fname, res_dir=None):
|
||||
""" db_fname: EnMicroMsg.db"""
|
||||
self.db_fname = db_fname
|
||||
self.db_conn = sqlite3.connect(self.db_fname)
|
||||
@@ -30,6 +31,8 @@ class WeChatDBParser(object):
|
||||
self.contacts = {}
|
||||
self.msgs_by_talker = defaultdict(list)
|
||||
|
||||
self.res = Resource(res_dir) if res_dir else None
|
||||
|
||||
def _parse_contact(self):
|
||||
contacts = self.cc.execute(
|
||||
"""
|
||||
@@ -63,7 +66,7 @@ SELECT {} FROM message
|
||||
if msgs is None:
|
||||
msgs = itertools.chain.from_iterable(self.msgs_by_talker.itervalues())
|
||||
for msg in msgs:
|
||||
if msg.type == 43:
|
||||
if msg.type == 34:
|
||||
ret.append(msg)
|
||||
return sorted(ret)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user