(self, handler, item)
| 361 | _version = "2.0" |
| 362 | |
| 363 | def add_item_elements(self, handler, item): |
| 364 | handler.addQuickElement("title", item["title"]) |
| 365 | handler.addQuickElement("link", item["link"]) |
| 366 | if item["description"] is not None: |
| 367 | handler.addQuickElement("description", item["description"]) |
| 368 | |
| 369 | # Author information. |
| 370 | if item["author_name"] and item["author_email"]: |
| 371 | handler.addQuickElement( |
| 372 | "author", "%s (%s)" % (item["author_email"], item["author_name"]) |
| 373 | ) |
| 374 | elif item["author_email"]: |
| 375 | handler.addQuickElement("author", item["author_email"]) |
| 376 | elif item["author_name"]: |
| 377 | handler.addQuickElement( |
| 378 | "dc:creator", |
| 379 | item["author_name"], |
| 380 | {"xmlns:dc": "http://purl.org/dc/elements/1.1/"}, |
| 381 | ) |
| 382 | |
| 383 | if item["pubdate"] is not None: |
| 384 | handler.addQuickElement("pubDate", rfc2822_date(item["pubdate"])) |
| 385 | if item["comments"] is not None: |
| 386 | handler.addQuickElement("comments", item["comments"]) |
| 387 | if item["unique_id"] is not None: |
| 388 | guid_attrs = {} |
| 389 | if isinstance(item.get("unique_id_is_permalink"), bool): |
| 390 | guid_attrs["isPermaLink"] = str(item["unique_id_is_permalink"]).lower() |
| 391 | handler.addQuickElement("guid", item["unique_id"], guid_attrs) |
| 392 | if item["ttl"] is not None: |
| 393 | handler.addQuickElement("ttl", item["ttl"]) |
| 394 | |
| 395 | # Enclosure. |
| 396 | if item["enclosures"]: |
| 397 | enclosures = list(item["enclosures"]) |
| 398 | if len(enclosures) > 1: |
| 399 | raise ValueError( |
| 400 | "RSS feed items may only have one enclosure, see " |
| 401 | "http://www.rssboard.org/rss-profile#element-channel-item-enclosure" |
| 402 | ) |
| 403 | enclosure = enclosures[0] |
| 404 | handler.addQuickElement( |
| 405 | "enclosure", |
| 406 | "", |
| 407 | { |
| 408 | "url": enclosure.url, |
| 409 | "length": enclosure.length, |
| 410 | "type": enclosure.mime_type, |
| 411 | }, |
| 412 | ) |
| 413 | |
| 414 | # Categories. |
| 415 | for cat in item["categories"]: |
| 416 | handler.addQuickElement("category", cat) |
| 417 | |
| 418 | |
| 419 | class Atom1Feed(SyndicationFeed): |
nothing calls this directly
no test coverage detected