MCPcopy
hub / github.com/django/django / add_item

Method add_item

django/utils/feedgenerator.py:165–213  ·  view source on GitHub ↗

Add an item to the feed. All args are expected to be strings except pubdate and updateddate, which are datetime.datetime objects, and enclosures, which is an iterable of instances of the Enclosure class.

(
        self,
        title,
        link,
        description,
        author_email=None,
        author_name=None,
        author_link=None,
        pubdate=None,
        comments=None,
        unique_id=None,
        unique_id_is_permalink=None,
        categories=(),
        item_copyright=None,
        ttl=None,
        updateddate=None,
        enclosures=None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

163 self.items = []
164
165 def add_item(
166 self,
167 title,
168 link,
169 description,
170 author_email=None,
171 author_name=None,
172 author_link=None,
173 pubdate=None,
174 comments=None,
175 unique_id=None,
176 unique_id_is_permalink=None,
177 categories=(),
178 item_copyright=None,
179 ttl=None,
180 updateddate=None,
181 enclosures=None,
182 **kwargs,
183 ):
184 """
185 Add an item to the feed. All args are expected to be strings except
186 pubdate and updateddate, which are datetime.datetime objects, and
187 enclosures, which is an iterable of instances of the Enclosure class.
188 """
189
190 def to_str(s):
191 return str(s) if s is not None else s
192
193 categories = categories and [to_str(c) for c in categories]
194 self.items.append(
195 {
196 "title": to_str(title),
197 "link": iri_to_uri(link),
198 "description": to_str(description),
199 "author_email": to_str(author_email),
200 "author_name": to_str(author_name),
201 "author_link": iri_to_uri(author_link),
202 "pubdate": pubdate,
203 "updateddate": updateddate,
204 "comments": to_str(comments),
205 "unique_id": to_str(unique_id),
206 "unique_id_is_permalink": unique_id_is_permalink,
207 "enclosures": enclosures or (),
208 "categories": categories or (),
209 "item_copyright": to_str(item_copyright),
210 "ttl": to_str(ttl),
211 **kwargs,
212 }
213 )
214
215 def num_items(self):
216 return len(self.items)

Callers 2

get_feedMethod · 0.80
test_atom_add_itemMethod · 0.80

Calls 2

iri_to_uriFunction · 0.90
appendMethod · 0.45

Tested by 1

test_atom_add_itemMethod · 0.64