v3.9 (unreleased)
+ * Catch and error out if a user adds a feed with a duplicate name.
* Split sender into both sendmail's -F and -f.
* Fix an error with SMTPConnectionError inhertence order ("does not take keyword arguments").
* Add a new `smtp-ssl-protocol` setting, to select acceptable protocols for SMTP connections.
class InvalidFeedName (InvalidFeedConfig):
- def __init__(self, name, **kwargs):
- message = "invalid feed name '{}'".format(name)
+ def __init__(self, name, message=None, **kwargs):
+ if not message:
+ message = 'invalid feed name {!r}'.format(name)
super(InvalidFeedName, self).__init__(
setting='name', message=message, **kwargs)
+class DuplicateFeedName (InvalidFeedName):
+ def __init__(self, name, **kwargs):
+ message = 'duplicate feed name {!r}'.format(name)
+ super(DuplicateFeedName, self).__init__(
+ name=name, message=message, **kwargs)
+
+
class ProcessingError (FeedError):
def __init__(self, parsed, feed, message=None, **kwargs):
if message is None:
feed-0 (None -> a@b.com)
>>> print(feeds.new_feed())
feed-1 (None -> a@b.com)
+ >>> print(feeds.new_feed(name='feed-1'))
+ Traceback (most recent call last):
+ ...
+ rss2email.error.DuplicateFeedName: duplicate feed name 'feed-1'
"""
+ feed_names = [feed.name for feed in self]
if name is None:
i = 0
while True:
name = '{}{}'.format(prefix, i)
- feed_names = [feed.name for feed in self]
if name not in feed_names:
break
i += 1
+ elif name in feed_names:
+ feed = self[name]
+ raise _error.DuplicateFeedName(name=feed.name, feed=feed)
feed = _feed.Feed(name=name, **kwargs)
self.append(feed)
return feed