How to use the feedparser.util.FeedParserDict function in feedparser

To help you get started, we’ve selected a few feedparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kurtmckee / feedparser / feedparser / util.py View on Github external
            norel = lambda link: FeedParserDict([(name, value) for (name, value) in link.items() if name != 'rel'])
            return [
github kurtmckee / feedparser / feedparser / namespaces / georss.py View on Github external
def _start_georssgeom(self, attrs_d):
        self.push('geometry', 0)
        context = self._get_context()
        context['where'] = FeedParserDict()
github kurtmckee / feedparser / feedparser / namespaces / _base.py View on Github external
def _start_enclosure(self, attrs_d):
        attrs_d = self._enforce_href(attrs_d)
        context = self._get_context()
        attrs_d['rel'] = 'enclosure'
        context.setdefault('links', []).append(FeedParserDict(attrs_d))
github kurtmckee / feedparser / feedparser / namespaces / _base.py View on Github external
def _start_link(self, attrs_d):
        attrs_d.setdefault('rel', 'alternate')
        if attrs_d['rel'] == 'self':
            attrs_d.setdefault('type', 'application/atom+xml')
        else:
            attrs_d.setdefault('type', 'text/html')
        context = self._get_context()
        attrs_d = self._enforce_href(attrs_d)
        if 'href' in attrs_d:
            attrs_d['href'] = self.resolve_uri(attrs_d['href'])
        expecting_text = self.infeed or self.inentry or self.insource
        context.setdefault('links', [])
        if not (self.inentry and self.inimage):
            context['links'].append(FeedParserDict(attrs_d))
        if 'href' in attrs_d:
            if (
                    attrs_d.get('rel') == 'alternate'
                    and self.map_content_type(attrs_d.get('type')) in self.html_types
            ):
                context['link'] = attrs_d['href']
        else:
            self.push('link', expecting_text)
github kurtmckee / feedparser / feedparser / namespaces / itunes.py View on Github external
def _start_itunes_image(self, attrs_d):
        self.push('itunes_image', 0)
        if attrs_d.get('href'):
            self._get_context()['image'] = FeedParserDict({'href': attrs_d.get('href')})
        elif attrs_d.get('url'):
            self._get_context()['image'] = FeedParserDict({'href': attrs_d.get('url')})
    _start_itunes_link = _start_itunes_image
github kurtmckee / feedparser / feedparser / namespaces / psc.py View on Github external
def _start_psc_chapters(self, attrs_d):
        context = self._get_context()
        if 'psc_chapters' not in context:
            self.psc_chapters_flag = True
            attrs_d['chapters'] = []
            context['psc_chapters'] = util.FeedParserDict(attrs_d)
github kurtmckee / feedparser / feedparser / namespaces / georss.py View on Github external
def _start_where(self, attrs_d):
        self.push('where', 0)
        context = self._get_context()
        context['where'] = FeedParserDict()
    _start_georss_where = _start_where
github kurtmckee / feedparser / feedparser / namespaces / psc.py View on Github external
def _start_psc_chapter(self, attrs_d):
        if self.psc_chapters_flag:
            start = self._get_attribute(attrs_d, 'start')
            attrs_d['start_parsed'] = _parse_psc_chapter_start(start)

            context = self._get_context()['psc_chapters']
            context['chapters'].append(util.FeedParserDict(attrs_d))
github kurtmckee / feedparser / feedparser / mixin.py View on Github external
def _add_tag(self, term, scheme, label):
        context = self._get_context()
        tags = context.setdefault('tags', [])
        if (not term) and (not scheme) and (not label):
            return
        value = FeedParserDict(term=term, scheme=scheme, label=label)
        if value not in tags:
            tags.append(value)