4 r"""An iCalendar feed (:RFC:`5545`)
6 >>> f = Feed(url='http://example.com/calendar.ics')
8 <Feed url:http://example.com/calendar.ics>
12 We can't fetch this dummy url, so load the content by hand.
15 >>> root_dir = os.curdir
16 >>> data_file = os.path.join(os.curdir, 'test', 'data', 'geohash.ics')
17 >>> with open(data_file, 'r') as data:
18 ... f.content = data.read().replace('\n', data.newlines)
19 ... assert data.newlines == '\r\n', data.newlines
20 >>> print(f) # doctest: +REPORT_UDIFF
23 PRODID:-//Example Calendar//NONSGML v1.0//EN
25 UID:2013-06-30@geohash.invalid
26 DTSTAMP:2013-06-30T00:00:00Z
27 DTSTART;VALUE=DATE:20130630
28 DTEND;VALUE=DATE:20130701
29 SUMMARY:XKCD geohashing\, Boston graticule
30 URL:http://xkcd.com/426/
31 LOCATION:Snow Hill\, Dover\, Massachusetts
32 GEO:42.226663,-71.28676
36 To get the CRLF line endings specified in :RFC:`5545`, use the
40 >>> stream = io.StringIO()
41 >>> f.write(stream=stream)
42 >>> stream.getvalue() # doctest: +ELLIPSIS
43 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\n...END:VCALENDAR\r\n'
45 def __init__(self, url, content=None):
47 self.content = content
51 return self.content.replace('\r\n', '\n').strip()
55 return '<{} url:{}>'.format(type(self).__name__, self.url)
58 raise NotImplementedError()
60 def write(self, stream):
61 stream.write(self.content)