some small change

This commit is contained in:
ppwwyyxx
2015-04-12 21:10:11 +08:00
parent 5cc0cefb2b
commit 987d8bda78
3 changed files with 17 additions and 6 deletions
+1 -1
View File
@@ -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 <[email protected]>
source compatibility.sh
+4 -4
View File
@@ -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 <[email protected]>
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")
+12 -1
View File
@@ -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 <[email protected]>
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))