-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_chatlog.py
executable file
·39 lines (28 loc) · 987 Bytes
/
read_chatlog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
"""
This script parses Empathy chat logs (in XML) and outputs
human readable text.
./read_chatlog.py [filename]
NOTE: Location of Empathy logs is at: $HOME/.local/share/TpLogger/logs
OUTPUT:
(20151127T22:38:10) Shahid Afridi: Ready for some cricket?
(20151127T23:36:50) Inzimam Al-Haq: No. Having dinner.
"""
import sys, os
from xml.dom import minidom
USAGE = './read_chatlog.py filename'
if len(sys.argv) != 2:
print "Following the following usage:"
print "\t" + USAGE
sys.exit(1)
filename=sys.argv[1]
if not os.path.isfile(filename):
print "File: {} does not exist".format(filename)
sys.exit(1)
xmldoc = minidom.parse(filename)
messages = xmldoc.getElementsByTagName('message')
for message in messages:
ind_message = '(' + message.attributes['time'].value + ') '
ind_message += message.attributes['name'].value + ': '
ind_message += message.childNodes[0].nodeValue
print ind_message