diff --git a/android-interact.sh b/android-interact.sh index aa29a1d..28065d7 100755 --- a/android-interact.sh +++ b/android-interact.sh @@ -1,6 +1,6 @@ #!/bin/bash -e # File: android-interact.sh -# Date: Sun Feb 01 17:26:48 2015 +0800 +# Date: Sun Apr 12 21:19:07 2015 +0900 # Author: Yuxin Wu source compatibility.sh diff --git a/report.sh b/count-message.sh similarity index 88% rename from report.sh rename to count-message.sh index 40e3566..7d496cb 100755 --- a/report.sh +++ b/count-message.sh @@ -1,16 +1,16 @@ #!/bin/bash -e -# File: android-interact.sh -# Date: Sat Mar 7 20:57:51 2015 +0800 +# File: count-message.sh +# Date: Sun Apr 12 21:01:01 2015 +0900 # Author: Kangjing Huang if [[ -z $1 ]] -then +then echo "Usage: $0 [Directory of text messages]" exit 1 fi -echo -e "Filename\tCounts of message\tCounts of chars\tCounts of words" +echo -e "Filename\tCounts of message\tCounts of chars\tCounts of words" SAVEIFS=$IFS IFS=$(echo -en "\n\b") diff --git a/libchat/libchat.py b/libchat/libchat.py index 0662163..360dc6a 100644 --- a/libchat/libchat.py +++ b/libchat/libchat.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- coding: UTF-8 -*- # File: libchat.py -# Date: Sat Mar 28 00:08:29 2015 +0800 +# Date: Sun Apr 12 21:08:51 2015 +0900 # Author: Yuxin Wu import sqlite3 import os @@ -14,6 +14,16 @@ NUM_FIELDS = 8 ChatMsgBase = namedtuple('ChatMsgBase', ['source', 'time', 'sender', 'chatroom', 'text', 'image', 'sound', 'extra_data']) +""" source: unicode, + time: datetime, + sender: unicode, + chatroom: unicode, + text: unicode, + image: string, + sound: string, + extra_data: string +""" + class ChatMsg(ChatMsgBase): def __repr__(self): # repr must return str? return "Msg@{}/{}-{}/{}/{}/{}/{}".format( @@ -56,6 +66,7 @@ class SqliteLibChat(object): ','.join(['?']*NUM_FIELDS)), tp) def add_msgs(self, msgs): + """ each message is a ChatMsg instance""" self.c = self.conn.cursor() for m in msgs: self._add_msg(SqliteLibChat.prefilter(m))