示例#1
0
文件: utils.py 项目: jammon/ics.py
 def test_parse_cal_datetime(self):
     cl = ContentLine.parse('DTSTART:20150701T060000')
     self.assertEqual(datetime(2015, 7, 1, 6), parse_cal_datetime(cl))
     cl = ContentLine.parse('DTSTART:20150701T060000Z')
     self.assertEqual(datetime(2015, 7, 1, 6, tzinfo=tzutc),
                      parse_cal_datetime(cl))
     cl = ContentLine.parse('DTSTART;TZID=America/New_York:20150701T060000Z')
     self.assertEqual(datetime(2015, 7, 1, 6, tzinfo=tzstr('America/New_York')),
                      parse_cal_datetime(cl))
示例#2
0
 def test_parse(self):
     for test, expected in itertools.chain(self.dataset.items(),
                                           self.parse_dataset.items()):
         got = ContentLine.parse(test)
         self.assertEqual(expected, got)
示例#3
0
 def test_parse(self):
     self.dataset2.update(self.dataset)
     for test in self.dataset2:
         expected = self.dataset2[test]
         got = ContentLine.parse(test)
         self.assertEqual(expected, got)
示例#4
0
 def test_timezone_not_dropped(self):
     line = ContentLine.parse("DTSTART;TZID=Europe/Berlin:20151104T190000")
     arrow = iso_to_arrow(line)
     self.assertIn("Europe/Berlin", str(arrow.tzinfo))
示例#5
0
def o_some_attr2bis(test, container):
    if test.some_attr2:
        container.append(ContentLine('ATTR2', value=test.some_attr2.upper()))
示例#6
0
    def test_required_raises(self):
        cont = Container("TEST")
        cont.append(ContentLine(name="PLOP", value="plip"))

        with self.assertRaises(ValueError):
            CT2._from_container(cont)
示例#7
0
    def test_multiple_unique_required(self):
        cont = Container("TEST")
        cont.append(ContentLine(name="OTHER", value="anything"))

        with self.assertRaises(ValueError):
            CT4._from_container(cont)
示例#8
0
def o_some_attr2(test, container):
    if test.some_attr:
        container.append(ContentLine('ATTR', value=test.some_attr.upper()))
示例#9
0
文件: property.py 项目: jammon/ics.py
 def test_datetime_with_timezone2(self):
     c = self.DTComponent()
     c.prop = datetime(2015, 7, 1, 6, tzinfo=new_york)
     self.assertEqual(c._properties,
                      {'PROP': ContentLine.parse('PROP;TZID=America/New_York:20150701T060000')})
示例#10
0
        else:
            dates[phases[i]] = get_date(phase)

    return dates


def get_date(phase):
    date, time = phase.split()
    date = [int(i) for i in date.split(':')]
    time = [int(i) for i in time.split(':')]
    return datetime.datetime(*date, *time)


calendar = Calendar()
calendar.extra.extend([
    ContentLine(name='X-ORIGINAL-URL',
                value='https://github.com/ibLeDy/2020-calendar-f1'),
    ContentLine(name='X-WR-CALNAME', value='F1 Calendar 2020')
])

with open('data/races.csv', 'r') as f:
    races = f.read().strip().splitlines()

with open('data/schedule.csv', 'r') as f:
    sessions = f.read().strip().splitlines()

schedule = {}
for s in sessions:
    name, fp1, fp2, fp3, q, r = s.split(',')
    schedule[name] = [fp1, fp2, fp3, q, r]

for race in races:
示例#11
0
def o_recipients(alarm, container):
    for email in alarm.recipients:
        container.append(
            ContentLine("ATTENDEE", value=escape_string("mailto:%s" % email)))
示例#12
0
def o_subject(alarm, container):
    container.append(
        ContentLine("SUMMARY", value=escape_string(alarm.subject or "")))
示例#13
0
def o_body(alarm, container):
    container.append(
        ContentLine("DESCRIPTION", value=escape_string(alarm.body or "")))
示例#14
0
 def test_timezone_not_dropped(self):
     line = ContentLine.parse("DTSTART;TZID=Europe/Berlin:20151104T190000")
     arrow = iso_to_arrow(line)
     self.assertIn("Europe/Berlin", str(arrow.tzinfo))
示例#15
0
 def test_parse(self):
     self.dataset2.update(self.dataset)
     for test in self.dataset2:
         expected = self.dataset2[test]
         got = ContentLine.parse(test)
         self.assertEqual(expected, got)