Esempio n. 1
0
 def add_entry(self, title, link, description, author_email=None,
     author_name=None, author_link=None, pubdate=None, comments=None,
     unique_id=None, enclosure=None, categories=(), entry_copyright=None,
     ttl=None, **kwargs):
     """
     Adds an entry to the feed. All args are expected to be Python Unicode
     objects except pubdate, which is a datetime.datetime object, and
     enclosure, which is an instance of the Enclosure class.
     """
     to_unicode = lambda s: force_unicode(s, strings_only=True)
     if categories:
         categories = [to_unicode(c) for c in categories]
     if ttl is not None:
         # Force ints to unicode
         ttl = force_unicode(ttl)
     entry = minimized({
         'title': to_unicode(title),
         'link': iri_to_uri(link),
         'description': to_unicode(description),
         'author_email': to_unicode(author_email),
         'author_name': to_unicode(author_name),
         'author_link': iri_to_uri(author_link),
         'pubdate': pubdate,
         'comments': to_unicode(comments),
         'unique_id': to_unicode(unique_id),
         'enclosure': enclosure,
         'categories': categories or (),
         'entry_copyright': to_unicode(entry_copyright),
         'ttl': ttl,
     })
     entry.update(kwargs)
     self.append(entry)
Esempio n. 2
0
 def __init__(self, title, link, description, language=None, author_email=None,
         author_name=None, author_link=None, subtitle=None, categories=None,
         feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs):
     to_unicode = lambda s: force_unicode(s, strings_only=True)
     if categories:
         categories = [force_unicode(c) for c in categories]
     if ttl is not None:
         # Force ints to unicode
         ttl = force_unicode(ttl)
     self.meta = minimized({
         'title': to_unicode(title),
         'link': iri_to_uri(link),
         'description': to_unicode(description),
         'language': to_unicode(language),
         'author_email': to_unicode(author_email),
         'author_name': to_unicode(author_name),
         'author_link': iri_to_uri(author_link),
         'subtitle': to_unicode(subtitle),
         'categories': categories or (),
         'feed_url': iri_to_uri(feed_url),
         'feed_copyright': to_unicode(feed_copyright),
         'id': feed_guid or link,
         'ttl': ttl,
     })
     self.meta.update(kwargs)
Esempio n. 3
0
 def add_item(
     self,
     title,
     link,
     description,
     author_email=None,
     author_name=None,
     author_link=None,
     pubdate=None,
     comments=None,
     unique_id=None,
     enclosure=None,
     categories=(),
     item_copyright=None,
     ttl=None,
     **kwargs
 ):
     """
     Adds an item to the feed. All args are expected to be Python Unicode
     objects except pubdate, which is a datetime.datetime object, and
     enclosure, which is an instance of the Enclosure class.
     """
     to_unicode = lambda s: force_unicode(s, strings_only=True)
     if categories:
         categories = [to_unicode(c) for c in categories]
     if ttl is not None:
         # Force ints to unicode
         ttl = force_unicode(ttl)
     item = {
         "title": to_unicode(title),
         "link": iri_to_uri(link),
         "description": to_unicode(description),
         "author_email": to_unicode(author_email),
         "author_name": to_unicode(author_name),
         "author_link": iri_to_uri(author_link),
         "pubdate": pubdate,
         "comments": to_unicode(comments),
         "unique_id": to_unicode(unique_id),
         "enclosure": enclosure,
         "categories": categories or (),
         "item_copyright": to_unicode(item_copyright),
         "ttl": ttl,
     }
     item.update(kwargs)
     self.items.append(item)
Esempio n. 4
0
 def __init__(
     self,
     title,
     link,
     description,
     language=None,
     author_email=None,
     author_name=None,
     author_link=None,
     subtitle=None,
     categories=None,
     feed_url=None,
     feed_copyright=None,
     feed_guid=None,
     ttl=None,
     **kwargs
 ):
     to_unicode = lambda s: force_unicode(s, strings_only=True)
     if categories:
         categories = [force_unicode(c) for c in categories]
     if ttl is not None:
         # Force ints to unicode
         ttl = force_unicode(ttl)
     self.feed = {
         "title": to_unicode(title),
         "link": iri_to_uri(link),
         "description": to_unicode(description),
         "language": to_unicode(language),
         "author_email": to_unicode(author_email),
         "author_name": to_unicode(author_name),
         "author_link": iri_to_uri(author_link),
         "subtitle": to_unicode(subtitle),
         "categories": categories or (),
         "feed_url": iri_to_uri(feed_url),
         "feed_copyright": to_unicode(feed_copyright),
         "id": feed_guid or link,
         "ttl": ttl,
     }
     self.feed.update(kwargs)
     self.items = []