@@ -0,0 +1,1709 @@
+#/usr/bin/python%0A%0Aimport re%0A%0Afrom lxml.html import parse%0Afrom utils import getContent%0A%0A%0A#%0A# CONSTANTS%0A#%0AMONTH_EXP = re.compile(%22%3CA href=%5C%22(?P%3Cyear%3E%5B0-9%5D*)-(?P%3Cmonth%3E.*)/thread.html%22)%0ATHREAD_EXP = re.compile(%22%22%22%3CLI%3E%3CA HREF=%22(?P%3Curl%3E.*)%22%3E(?P%3Csubject%3E.*)%5Cn%3C/A%3E%3CA NAME=%22%5B0-9%5D*%22%3E%5C&nbsp;%3C/A%3E%5Cn%3CI%3E(?P%3Cauthor%3E.*)%5Cn%3C/I%3E%5Cn%22%22%22)%0A%0A%0Aclass MailingList():%0A    %22%22%22%0A    Create a class that represents a mailing list%0A    %22%22%22%0A%0A    def __init__(self, url):%0A        %22%22%22%0A        Create the class setting the url%0A        %22%22%22%0A        self.__url = url%0A%0A    def listMonthTreads(self):%0A        %22%22%22%0A        Retrieves months to search threads%0A        %22%22%22%0A        # download url%0A        content = getContent(self.__url)%0A%0A        months = %5B i.groupdict() for i in MONTH_EXP.finditer(content) %5D%0A%0A        # get months%0A        return months%0A%0A    def listThreads(self, month, year):%0A        %22%22%22%0A        List threads each month%0A        %22%22%22%0A        content = getContent(%22%25s/%25s-%25s/thread.html%22 %25 (self.__url, year, month))%0A    %0A        threads = %5B i.groupdict() for i in THREAD_EXP.finditer(content) %5D%0A    %0A        # append full url%0A        for i in range(len(threads)):%0A            threads%5Bi%5D%5B%22url%22%5D = %22%25s/%25s-%25s/%25s%22 %25 (self.__url, year, month, threads%5Bi%5D%5B%22url%22%5D)%0A%0A        return threads%0A%0A    def getPatch(self, url):%0A        %22%22%22%0A        Retrieves patch content %0A        %22%22%22%0A        doc = parse(url).getroot()%0A%0A        for i in doc.body.getchildren():%0A            if i.tag == %22pre%22:%0A                return i.text_content()%0A%0Aa = MailingList(%22http://lists.ovirt.org/pipermail/kimchi-devel%22)%0Aprint a.listMonthTreads()%0Aprint a.listThreads(%22February%22, %222015%22)%0A%0Aprint a.getPatch(%22http://lists.ovirt.org/pipermail/kimchi-devel/2015-February/009616.html%22)%0A

Add mailing list parser