Esempio n. 1
0
    def create_programme(self, programme):
        cer = programme["cod_evento_rejilla"]

        if cer in self.cache:
            return self.cache.get(cer)

        info = {
            "channel": programme["cod_cadena_tv"],
            "title": programme["des_evento_rejilla"],
            "category": programme["des_genero"],
            "start": DateTime().parse(programme["f_evento_rejilla"]),
            "stop": DateTime().parse(programme["f_fin_evento_rejilla"])
        }

        cee = programme["cod_elemento_emision"]
        if cee and DOWNLOAD_EXTRA_INFO:
            info.update(Movistar.get_extra_info(cee))

        # DAYS_TO_DOWNLOAD + 1 we add the day before data | 86400 seconds in a day
        expire_time = (DAYS_TO_DOWNLOAD + 1) * 86400
        self.cache.set(cer, info, expire=expire_time)

        return info
Esempio n. 2
0
 def set_post(self,
              title="",
              category="",
              describes="",
              id="",
              tag="",
              content="",
              datetime=DateTime()):
     self.title = title
     self.category = category
     self.describes = describes
     self.id = id
     if type(tag) == str:
         self.tag = convert_str_to_array(tag).copy()
     elif type(tag) == list:
         self.tag = tag[:]
     self.content = content
     self.date = datetime
Esempio n. 3
0
 def __init__(self,
              title="",
              category="",
              describes="",
              id="",
              tag="",
              content="",
              times=0,
              datetime=DateTime()):
     self.title = title
     self.category = category
     self.describes = describes
     self.id = id
     if type(tag) is str:
         self.tag = convert_str_to_array(tag).copy()
     elif type(tag) is list:
         self.tag = tag.copy()
     self.content = content
     self.date = datetime
     self.times = times
 def test_equal_day(self):
     assert DateTime(1, 0, 0) == DateTime(1, 0, 0)
Esempio n. 5
0
 def test_bad_init_6(self):
     with self.assertRaises(TypeError):
         dt = DateTime(second="ololo")
Esempio n. 6
0
 def set_date(self, datetime=DateTime()):
     self.date = datetime
Esempio n. 7
0
        while True:
            s = SequenceMatcher(None, first_team, second_team)
            substring = s.find_longest_match(0, len(first_team), 0,
                                             len(second_team))
            if substring.size < min(3, min_initial_length):
                break
            substrings_total_length += substring.size
            # print(first_team[substring.a:substring.b])
            first_team = first_team[:substring.a] + first_team[substring.a +
                                                               substring.size:]
            second_team = second_team[:substring.
                                      b] + second_team[substring.b +
                                                       substring.size:]

        similarity = substrings_total_length / min_initial_length + \
                     (substrings_total_length - max_initial_length) / (10 * max_initial_length)
        return similarity


if __name__ == '__main__':
    certainty = 0.5
    comparator = MatchComparator()
    m1 = Match(MatchTitle(['jd gaming', 'team we']), '123',
               DateTime(2020, 12, 26, 12, 30), 1, [])
    m2 = Match(MatchTitle(['jd', 'we']), '321', DateTime(2020, 12, 26, 13), 2,
               [])
    similarity = comparator.calculate_matches_similarity(m1, m2, certainty)
    print(similarity)
    print(comparator.similar(m1, m2, certainty))
    print(comparator.similarities)
 def test_not_in_range(self):
     sut = DateRange(DateTime(0, 0, 0), DateTime(0, 1, 0))
     assert not sut.in_range(DateTime(0, 2, 0))
 def test_not_greater_day(self):
     assert not DateTime(2, 0, 0) < DateTime(1, 0, 0)
Esempio n. 10
0
 def test_greater_hour(self):
     assert DateTime(0, 0, 0) < DateTime(0, 1, 0)
Esempio n. 11
0
 def test_good_not_equal(self):
     dt_1 = DateTime()
     dt_2 = DateTime(second=800)
     self.assertNotEqual(dt_1, dt_2)
Esempio n. 12
0
 def test_bad_not_equal(self):
     dt_1 = DateTime()
     dt_2 = DateTime()
     self.assertEqual(dt_1, dt_2)
Esempio n. 13
0
 def test_good_equal(self):
     dt_1 = DateTime()
     dt_2 = DateTime()
     self.assertEqual(dt_1, dt_2)
Esempio n. 14
0
 def test_bad_equal(self):
     dt_1 = DateTime()
     dt_2 = DateTime(second=600)
     self.assertNotEqual(dt_1, dt_2)
Esempio n. 15
0
 def test_greater_1(self):
     dt_1 = DateTime()
     dt_2 = DateTime(second=60)
     self.assertGreater(dt_2, dt_1)
Esempio n. 16
0
 def test_lesser_1(self):
     dt_1 = DateTime()
     dt_2 = DateTime(second=60)
     self.assertLess(dt_1, dt_2)
Esempio n. 17
0
 def test_good_init_1(self):
     dt = DateTime(year=2019, month=11, day=7)
     self.assertIsInstance(dt, DateTime)
Esempio n. 18
0
 def test_not_equal_day(self):
     assert DateTime(0, 0, 0) != DateTime(1, 0, 0)
Esempio n. 19
0
 def test_greater_day(self):
     assert DateTime(0, 0, 0) < DateTime(1, 0, 0)
Esempio n. 20
0
 def test_less_hour(self):
     assert DateTime(0, 1, 0) > DateTime(0, 0, 0)
Esempio n. 21
0
 def test_not_greater_equal_day(self):
     assert not DateTime(1, 0, 0) <= DateTime(0, 0, 0)
Esempio n. 22
0
 def test_less_minute(self):
     assert DateTime(0, 0, 1) > DateTime(0, 0, 0)
Esempio n. 23
0
 def test_in_range(self):
     sut = DateRange(DateTime(3, 22, 0), DateTime(3, 24, 0))
     assert sut.in_range(DateTime(3, 23, 0))
Esempio n. 24
0
 def test_not_greater_equal_hour(self):
     assert not DateTime(0, 2, 0) <= DateTime(0, 1, 0)
Esempio n. 25
0
 def test_greater_minute(self):
     assert DateTime(0, 0, 0) < DateTime(0, 0, 1)
Esempio n. 26
0
 def test_not_greater_equal_minute(self):
     assert not DateTime(0, 0, 2) <= DateTime(0, 0, 1)
Esempio n. 27
0
 def test_bad_init_4(self):
     with self.assertRaises(TypeError):
         dt = DateTime(hour="ololo")
Esempio n. 28
0
 def test_not_equal(self):
     assert DateTime(0, 0, 0) != DateTime(0, 1, 0)
Esempio n. 29
0
 def test_equal(self):
     assert DateTime(0, 0, 0) == DateTime(0, 0, 0)
Esempio n. 30
0
 def test_bad_init_5(self):
     with self.assertRaises(TypeError):
         dt = DateTime(minute="ololo")