Esempio n. 1
0
    def find_diff(self, filename):
        """
            Find delta between the new filename (arg) and the previous

        :param filename: new data filename
        :return: list of differences
        """

        old_d = digester.Digester()
        new_d = digester.Digester()
        old_data_fn = self.data_filename

        self.logger.info("Diff old = %s / new = %s" % (old_data_fn, filename))

        old_sha_data = None
        if old_data_fn:
            old_sha_data = old_d.digest(old_data_fn)

        new_sha_data = new_d.digest(filename)

        diff_data = []

        for (sha, linenum) in new_sha_data.items():
            if not old_sha_data or sha not in old_sha_data:
                diff_data.append((sha, linenum + 1, new_d.data[linenum]))
        return diff_data
Esempio n. 2
0
    def test_equal_data(self):
        self.logger.info("  TEST test_equal_data")

        d = digester.Digester()
        dig1 = d.digest(
            "test/files/PS_LibreAcces_Dipl_AutExerc_201807300827.txt")
        self.logger.info(len(dig1))

        dig2 = d.load_digest(
            "test/files/PS_LibreAcces_Dipl_AutExerc_201807300827.txt.sha")
        self.logger.info(len(dig2))

        self.assertEqual(len(dig1), len(dig2))
Esempio n. 3
0
 def process(self, date="today"):
     if date == "today":
         date = datetime.datetime.strftime(datetime.datetime.now(),
                                           "%d-%b-%Y")
     messageIds = self.fetcher.fetchMessageIdsForDate(date)
     messageTexts = self.fetcher.fetchMessageTextByIds(messageIds)
     processor = digester.Digester()
     for message in messageTexts.itervalues():
         processor.parseEmail(message)
     print "\n\n\n\n"
     # digest = processor.getDigest()
     # print (digest)
     # self.fetcher.createMessage(digest)
     digest = processor.templateDigest('templates/test.j2')
     self.fetcher.createMessage(digest, "html")
     print(digest)
Esempio n. 4
0
    def test_time(self):
        d = digester.Digester()
        start_date = datetime.datetime.now()
        data = d.make_digest(
            "/opt/test/test/files/Extraction_Correspondance_MSSante_201807310813.txt"
        )
        end_date = datetime.datetime.now()

        delta = end_date - start_date
        self.logger.info("Start : %s" % start_date.isoformat())
        self.logger.info("End   : %s" % end_date.isoformat())

        self.logger.info("Data : %s" % (delta.total_seconds()))

        self.assertEqual(len(data), 136694)
        self.assertLess(int(delta.total_seconds()), 10)
 def setUp(self):
     self.digester = digester.Digester()