source: http://home-gym-fitness-equipment.co.uk/files/log-book.jpg


This is the second lucky month that the Empathy icon lies on the top gnome-panel of my desktop. Well it is... let's say ok when compared with Pidgin. I love see Empathy developers add the buddy pounce function too. It was after the fresh F13 installation that I tried to give Empathy a try. It was pre-packaged with the the system (formerly it was Pidgin) and most importantly Open Source is all about Choice.

Empathy, as Pidgin does keeps a log of all the conversations we had via Empathy. Yeah, this can be deactivated also. The chat files of Empathy resides in ~/.local/share/Empathy/logs and I found them to be a little messy. They include all the technical data and other stuff and it makes us hard to find the messages. So I though to get it to a more human friendly and readable format and wrote the following python code. This for me works fine, and if there are any bugs, suggestions to improve, please leave a comment.

#!/usr/bin/python2.6
#
# W.H. Kalpa Pathum <callkalpa@gmail.com>
# 6th August, 2010
#
#    empathy_log.py
# This script formats a empathy log file in a more human readable way
# usage : empathy_log <empathy log file>
#

import re
import sys

msg_d = ''

def print_output(message_data):
    global msg_d
    
    # print the conversation date
    if msg_d != message_data[0]:
        msg_d = message_data[0]
        print 'Conversation with', message_data[2], 'on', msg_d

    print '('+ message_data[1]+ ')',  message_data[2], ':',  message_data[3]

def main(filename):
    f = open(filename, 'r')
    # read line by line and extract message details
    lines = f.readlines()

    for line in lines[3:-1]: # except first three lines and last line
        match = re.findall('^<message time=\'(\d+)T([\d:]+)\' [\w\W]+ name=\'([\w\W]+)\' token=[\w\W]+>([\w\W]+)<', line)
        if match:

            for item in match:
                # format msg_d
                d=item[0][:4] + '-' + item[0][4:6] + '-' + item[0][6:]
           
                message_data = [d, item[1], item[2], item[3]]
                print_output(message_data)
       
        # if the pattern is not found, print the modified line
        else:
            print re.sub('<[/message][\w\W]*>', '', line),

    f.close()

if __name__ == '__main__':
    main(sys.argv[1]) 


DOWNLOAD
3

View comments

  1. Or, you could just use the Empathy log viewer :)

    ReplyDelete
  2. yep now it has that feature.

    ReplyDelete
  3. Anonymous6:06 PM

    This was useful to me, as I wanted to print one of my logs. thanks.

    ReplyDelete

A late announcement, a little more than 2 years, I moved to Medium. I won't be making any new posts here in this blog. Please refer/follow https://medium.com/@callkalpa for the latest articles.
0

Add a comment

About Me
About Me
Subscribe
Subscribe
Popular Posts
Popular Posts
  • "The Snare is a poem which evokes positive attitudes within the reader." (1) Which kind of attitudes are evoked? (2) Show them wit...
  • "Island Spell" by Wendy Whatmore vividly describes a beautiful island. The starts her poem saying that she was caught in an island...
  • Try configuring your SLT ADSL connection yourself. Don't WASTE money for SLT . Here are the settings. Type : PPP...
  • To use java tools (javac, java, applet viewer etc.) from anywhere in the dos prompt java should be configured. Suppose that you have already...
  • A late announcement, a little more than 2 years, I moved to Medium. I won't be making any new posts here in this blog. Please refer/foll...
  • SOURCE: http://www.avidtrader.com/wordpress/wp-content/uploads/2013/01/reports.jpg Recently I was involved in developing a registration...
  • Welcome to WSO2 Application Server 6.0.0, the successor of WSO2 Carbon based Application Server. WSO2 Application Server 6.0.0 is a complet...
  • I recently came across this requirement where a  xsd:datetime  in the payload is needed to be converted to a different date time format as ...
  • Dialog GSM offers its latest service,Budget SMS, to both post paid and pre paid customers. With this service you will be able to send D2D SM...
  • Photo Credit : Prima Yogi FAD Singapore 2015 was held on 5th and 6th of December in Singapore and I participated at the event. FAD (F...
Labels
My Links
Blogs I read
Blogs I read
Loading