#!/usr/bin/env python # -*- coding: iso-8859-1 -*- import os import time import datetime class EmailMap: def __init__(self): templateFile = open(os.path.join(os.path.dirname(__file__), "template/map.html"), "r") self.__template = templateFile.read() templateFile.close() self.__emails = [] self.__pointsIndex = self.__template.find("%%POINTS%%") def addEmail(self, email): if email.location()[1][0] == "" and email.location()[1][1] == "": return #Country level hits are not sutiable self.__emails.append(email) def writeMap(self, outfile): self.__emails.sort() outfile.write(self.__template[:self.__pointsIndex]); points = [] for index, email in enumerate(self.__emails): outfile.write(("\t\t\tnew Location(%s, %s, \"%s\", \"%s\", %s)" % (email.location()[0][0], email.location()[0][1], email.ip, "%s, %s, %s" % email.location()[1], time.mktime(email.date.timetuple()) * 1000)).encode("utf-8")) points.append((float(email.location()[0][0]), float(email.location()[0][1]))) if index < len(self.__emails) - 1: outfile.write(",\n") outfile.write(self.__template[self.__pointsIndex + 10:])