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. """ item = { 'title': title, 'link': iri_to_uri(link), 'description': description, 'author_email': author_email, 'author_name': author_name, 'author_link': iri_to_uri(author_link), 'pubdate': pubdate, 'comments': comments, 'unique_id': unique_id, 'enclosure': enclosure, 'categories': categories or (), 'item_copyright': item_copyright, 'ttl': ttl, } item.update(kwargs) self.items.append(item)
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): self.feed = { 'title': title, 'link': link, 'description': description, 'language': language, 'author_email': author_email, 'author_name': author_name, 'author_link': author_link, 'subtitle': subtitle, 'categories': categories or (), 'feed_url': iri_to_uri(feed_url), 'feed_copyright': feed_copyright, 'id': feed_guid or link, 'ttl': ttl, } self.items = []
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): """ 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. """ self.items.append({ 'title': title, 'link': iri_to_uri(link), 'description': description, 'author_email': author_email, 'author_name': author_name, 'author_link': author_link, 'pubdate': pubdate, 'comments': comments, 'unique_id': unique_id, 'enclosure': enclosure, 'categories': categories or (), 'item_copyright': item_copyright, 'ttl': ttl, })
def __update_author(author): """Update the given author entity.""" value = save_xpath(author, './@name') author_id = value.replace(' ', '-') uri = '%s/author/%s' % (current_app.config['API_URL'], author_id) initial = value.split(' ')[-1] or 'A' href_raw = 'http://www.zeit.de/autoren/%s/%s/index.xml' href = href_raw % (initial[0], value.replace(' ', '_')) href = href if urllib.urlopen(iri_to_uri(href)).getcode() == 200 else '' query = 'REPLACE INTO author VALUES (?, ?, ?, ?, ?);' g.db.execute(query, (href, author_id, 'author', uri, value))
def build_absolute_uri(self, location=None): """ Builds an absolute URI from the location and the variables available in this request. If no location is specified, the absolute URI is built on ``request.get_full_path()``. """ if not location: location = '' if not absolute_http_url_re.match(location): current_uri = '%s://%s%s' % (self.is_secure() and 'https' or 'http', self.get_host(), self.path) location = urljoin(current_uri, location) return iri_to_uri(location)
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): if categories: categories = [force_unicode(c) for c in categories] self.feed = { 'title': title, 'link': iri_to_uri(link), 'description': description, 'language': language, 'author_email': author_email, 'author_name': author_name, 'author_link': iri_to_uri(author_link), 'subtitle': subtitle, 'categories': categories or (), 'feed_url': iri_to_uri(feed_url), 'feed_copyright': feed_copyright, 'id': feed_guid or link, 'ttl': ttl, } self.feed.update(kwargs) self.items = []
def __init__(self, url, length, mime_type): "All args are expected to be Python Unicode objects" self.length, self.mime_type = length, mime_type self.url = iri_to_uri(url)