Empathy log

Empathy කියන්නෙ multi protocol chat client එකක්. chat client එකක් කියන්නෙ yahoo messenger, gtalk වගේ හැබැයි Empathy, multi protocol, ඒ කියන්නෙ yahoo, gmail සහ තවත් බොහෝ සේවාවල chat පහසුකම මේ හරහා භාවිතා කරන්න පුළුවන්. වැඩේ ලේසියි. එක වැඩසටහනයිනේ. මම මේකට මීට කලින් භාවිතා කලේ නම් Pidgin. Empathy ආව මුල් කාලෙ දාල බැලුවට ඒක එච්චර හිතට ඇල්ලුවෙ නැති නිසා Pidginම පාව්චිච් කරා. ළඟදි Fedora 13 අලුතින්ම දාපු වෙලාවෙ ඉදන් තමයි Empathy පූර්ණ කාලීනව පාවිච්චි කරන්න ගත්තෙ. දැන් Fedora වල පෙරනිමියෙන් එන්නෙ Empathy කලින් ආවෙ Pidgin. Empathy හොඳයි අවුලක් නෑ. Pidgin වල තියෙන සමහර කොටස් මේකෙ නෑ, අලුත් ඒවා තියෙනව. එහෙම වෙන්න එපැයි නේද?

කතා කරන්න ආවෙ ඒ ගැන නෙවේ. අද මට ඕන වුණා Empathy chat log එක බලන්න. මේවා තියෙන්නෙ ~/.local/share/Empahy/logs කියන තැන. ~ කිව්වෙ නිවාස බහාලුම (home folder). හැබැයි මේ log file බලන්න ටිකක් අමාරුයි. ඒ කිව්වෙ තොරතුරු වැඩියෙන් තියෙනව. අපිට ඕන ඒවා තෝරල බේරල ගන්න ටිකක් අමාරුයි. ඒක නිසා මම පොඩි python script එකක් ලිව්වා. මේක මම පරීක්ෂා කරල file වලටනම් හරිගියා. මොකක්හරි අවුලක් තියෙනවනම් හරි දියුණු කරන්න අදහසක් තියෙනවනම් comment එකක් දාන්න.


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

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('^([\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])


මෙතනින් බාගන්න


3 responses to “Empathy log

ප්‍රතිචාරයක් ලබාදෙන්න