123456789101112131415161718192021222324 |
- import sys
- from subprocess import Popen, PIPE
- from min_rss_gen.generator import start_rss, gen_item
- import xml.etree.ElementTree
-
- FEED_LINK = 'https://linux.die.net/man/6/fortune'
- FEED_TITLE = 'Fortune'
- FEED_DESCRIPTION = 'Random, hopefully interesting, adages'
- NUM_ITEMS = 10
-
- rss_items = []
-
- for i in range(NUM_ITEMS):
- with Popen(['fortune', '-s'], encoding='utf-8', stdout=PIPE) as fortune:
- rss_items.append(gen_item(title=fortune.stdout.read()))
-
- rss_xml_element = start_rss(
- title=FEED_TITLE, link=FEED_LINK,
- description=FEED_DESCRIPTION, items=rss_items)
-
- sys.stdout.write(str(
- xml.etree.ElementTree.tostring(
- rss_xml_element, encoding='utf-8', method='xml'),
- 'utf-8'))
|