MCPcopy
hub / github.com/django/django / add_item_elements

Method add_item_elements

django/utils/feedgenerator.py:470–520  ·  view source on GitHub ↗
(self, handler, item)

Source from the content-addressed store, hash-verified

468 handler.endElement("entry")
469
470 def add_item_elements(self, handler, item):
471 handler.addQuickElement("title", item["title"])
472 handler.addQuickElement("link", "", {"href": item["link"], "rel": "alternate"})
473
474 if item["pubdate"] is not None:
475 handler.addQuickElement("published", rfc3339_date(item["pubdate"]))
476
477 if item["updateddate"] is not None:
478 handler.addQuickElement("updated", rfc3339_date(item["updateddate"]))
479
480 # Author information.
481 if item["author_name"] is not None:
482 handler.startElement("author", {})
483 handler.addQuickElement("name", item["author_name"])
484 if item["author_email"] is not None:
485 handler.addQuickElement("email", item["author_email"])
486 if item["author_link"] is not None:
487 handler.addQuickElement("uri", item["author_link"])
488 handler.endElement("author")
489
490 # Unique ID.
491 if item["unique_id"] is not None:
492 unique_id = item["unique_id"]
493 else:
494 unique_id = get_tag_uri(item["link"], item["pubdate"])
495 handler.addQuickElement("id", unique_id)
496
497 # Summary.
498 if item["description"] is not None:
499 handler.addQuickElement("summary", item["description"], {"type": "html"})
500
501 # Enclosures.
502 for enclosure in item["enclosures"]:
503 handler.addQuickElement(
504 "link",
505 "",
506 {
507 "rel": "enclosure",
508 "href": enclosure.url,
509 "length": enclosure.length,
510 "type": enclosure.mime_type,
511 },
512 )
513
514 # Categories.
515 for cat in item["categories"]:
516 handler.addQuickElement("category", "", {"term": cat})
517
518 # Rights.
519 if item["item_copyright"] is not None:
520 handler.addQuickElement("rights", item["item_copyright"])
521
522
523# This isolates the decision of what the system default is, so calling code can

Callers 2

write_itemsMethod · 0.95
write_itemsMethod · 0.45

Calls 4

rfc3339_dateFunction · 0.85
get_tag_uriFunction · 0.85
addQuickElementMethod · 0.80
startElementMethod · 0.80

Tested by

no test coverage detected