

def clean(self):
    '\n        Checks to make sure a feed url is valid and gets the feed title\n        and domain.\n        '
    feed_url = self.cleaned_data.get('url')
    if (not feed_url):
        return self.cleaned_data
    feed = feedparser.parse(feed_url)
    if feed['bozo']:
        import logging
        if (isinstance(feed['bozo_exception'], feedparser.ThingsNobodyCaresAboutButMe) or feed['entries']):
            logging.warning(feed['bozo_exception'])
        else:
            self._errors['url'] = ErrorList([('This is not a valid feed: %s' % feed['bozo_exception'])])
            logging.error(feed['bozo_exception'])
            del self.cleaned_data['url']
            return self.cleaned_data
    feed_info = feed.get('feed')
    if (not feed_info.get('title')):
        self._errors['url'] = ErrorList(['This is not a valid feed: The feed title is empty'])
        del self.cleaned_data['url']
        return self.cleaned_data
    self.cleaned_data['name'] = feed_info['title']
    self.instance.name = self.cleaned_data['name']
    self.cleaned_data['domain'] = get_url_domain(feed_url)
    self.instance.domain = self.cleaned_data['domain']
    self.instance.permalink = self.cleaned_data.get('href')
    return self.cleaned_data

dataset/ETHPy150Open IanLewis/django-lifestream/lifestream/admin.py FeedCreationForm.clean/original