#!/usr/bin/python import os import re channel = "#fi.muni.cz" fileIn = "fimunicz-logs" fileOut = "fimunicz-logs2" os.remove(fileOut) for line in open(fileIn, "r").readlines(): if line[0] == '*': line = re.sub('\*\*\*\* BEGIN LOGGING AT', '--- Log opened', line) line = re.sub('\*\*\*\* ENDING LOGGING AT', '--- Log closed', line) elif len(line) > 0: line = line[7:] if line[9:12] == "-->": line = re.sub('-->', '-!-', line, 1) elif line[9:12] == "<--": line = re.sub('<--', '-!-', line, 1) elif line[9:12] == "---": line = re.sub('---', '-!-', line, 1) line = re.sub('has changed the topic to:', 'changed the topic of " + channel + " to:', line) line = re.sub('was kicked by', 'was kicked from ' + channel + ' by', line) open(fileOut, "a").write(line)