improved error messages

This commit is contained in:
Lars Kiesow 2013-05-20 14:23:21 +02:00
parent d2a3fa62ff
commit 4a7e7ad83c

View file

@ -94,7 +94,10 @@ class FeedGenerator(object):
self.__atom_feed_xml_lang self.__atom_feed_xml_lang
if not ( self.__atom_id and self.__atom_title and self.__atom_updated ): if not ( self.__atom_id and self.__atom_title and self.__atom_updated ):
raise ValueError('Required fields not set') missing = ', '.join(([] if self.__atom_title else ['title']) + \
([] if self.__atom_id else ['id']) + \
([] if self.__atom_updated else ['updated']))
raise ValueError('Required fields not set (%s)' % missing)
id = etree.SubElement(feed, 'id') id = etree.SubElement(feed, 'id')
id.text = self.__atom_id id.text = self.__atom_id
title = etree.SubElement(feed, 'title') title = etree.SubElement(feed, 'title')
@ -222,7 +225,10 @@ class FeedGenerator(object):
nsmap={'atom': 'http://www.w3.org/2005/Atom'} ) nsmap={'atom': 'http://www.w3.org/2005/Atom'} )
channel = etree.SubElement(feed, 'channel') channel = etree.SubElement(feed, 'channel')
if not ( self.__rss_title and self.__rss_link and self.__rss_description ): if not ( self.__rss_title and self.__rss_link and self.__rss_description ):
raise ValueError('Required fields not set') missing = ', '.join(([] if self.__rss_title else ['title']) + \
([] if self.__rss_link else ['link']) + \
([] if self.__rss_description else ['description']))
raise ValueError('Required fields not set (%s)' % missing)
title = etree.SubElement(channel, 'title') title = etree.SubElement(channel, 'title')
title.text = self.__rss_title title.text = self.__rss_title
link = etree.SubElement(channel, 'link') link = etree.SubElement(channel, 'link')
@ -375,6 +381,7 @@ class FeedGenerator(object):
if not title is None: if not title is None:
self.__atom_title = title self.__atom_title = title
self.__rss_title = title self.__rss_title = title
print 'rss-title: ', self.__rss_title
return self.__atom_title return self.__atom_title