o
    þÞh¡$  ã                   @   sÈ   d dl mZmZ d dlmZ d dlmZmZ d dlm	Z	m
Z
 d dlmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZmZ d dlmZ ddd„ZG dd„ deƒZG dd„ dƒZdS )é    )Úgetattr_staticÚunwrap)Úget_current_site)ÚImproperlyConfiguredÚObjectDoesNotExist)ÚHttp404ÚHttpResponse)ÚTemplateDoesNotExistÚloader)Úfeedgenerator)Ú
iri_to_uri)Úescape)Ú	http_date)Úget_default_timezoneÚis_naiveÚ
make_aware)Úget_languageFc                 C   sF   |rdnd}|  d¡rd||f }|S |  d¡s!td|| |f ƒ}|S )NÚhttpsÚhttpz//z%s:%s)zhttp://zhttps://zmailto:z	%s://%s%s)Ú
startswithr   )ÚdomainÚurlÚsecureÚprotocol© r   ú`/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/contrib/syndication/views.pyÚ
add_domain   s   

þr   c                   @   s   e Zd ZdS )ÚFeedDoesNotExistN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r      s    r   c                   @   sx   e Zd ZejZdZdZdZdd„ Z	dd„ Z
dd„ Zdd	„ Zd
d„ Zddd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚFeedNc                 O   s†   z| j |g|¢R i |¤Ž}W n ty   tdƒ‚w |  ||¡}t|jd�}t| dƒs0t| dƒr;t| ¡  	¡ ƒ|j
d< | |d¡ |S )NzFeed object does not exist.)Úcontent_typeÚitem_pubdateÚitem_updateddatezLast-Modifiedzutf-8)Ú
get_objectr   r   Úget_feedr   r"   Úhasattrr   Úlatest_post_dateÚ	timestampÚheadersÚwrite)ÚselfÚrequestÚargsÚkwargsÚobjÚfeedgenÚresponser   r   r   Ú__call__#   s   ÿ

ÿzFeed.__call__c                 C   s   t t|ƒƒS ©N)r   Ústr©r,   Úitemr   r   r   Ú
item_title3   s   zFeed.item_titlec                 C   s   t |ƒS r4   )r5   r6   r   r   r   Úitem_description7   s   zFeed.item_descriptionc                 C   s*   z|  ¡ W S  ty   td|jj ƒ‚w )NzcGive your %s class a get_absolute_url() method, or define an item_link() method in your Feed class.)Úget_absolute_urlÚAttributeErrorr   Ú	__class__r   r6   r   r   r   Ú	item_link:   s   
ÿÿÿzFeed.item_linkc                 C   sF   |   d|¡}|r!tjt|ƒt|   d|¡ƒt|   d|¡ƒd�}|gS g S )NÚitem_enclosure_urlÚitem_enclosure_lengthÚitem_enclosure_mime_type)r   ÚlengthÚ	mime_type)Ú_get_dynamic_attrr   Ú	Enclosurer5   )r,   r7   Úenc_urlÚencr   r   r   Úitem_enclosuresC   s   ýzFeed.item_enclosuresc                 C   s²   zt | |ƒ}W n ty   | Y S w t|ƒrWt|ƒ}z|j}W n ty1   t|jƒ}|j}Y nw |jsKtt| |j	d ƒt
ƒsKtd|›d|j	›d�ƒ‚|jdkrT||ƒS |ƒ S |S )NzFeed method z decorated by z needs to use @functools.wraps.é   )Úgetattrr;   Úcallabler   Ú__code__r3   Úco_argcountÚ
isinstancer   r   Ústaticmethodr   )r,   Úattnamer0   ÚdefaultÚattrÚfuncÚcoder   r   r   rC   N   s.   ÿ


þÿÿ
zFeed._get_dynamic_attrc                 C   ó   i S )zy
        Return an extra keyword arguments dictionary that is used when
        initializing the feed generator.
        r   )r,   r0   r   r   r   Úfeed_extra_kwargsl   ó   zFeed.feed_extra_kwargsc                 C   rT   )zƒ
        Return an extra keyword arguments dictionary that is used with
        the `add_item` call of the feed generator.
        r   r6   r   r   r   Úitem_extra_kwargss   rV   zFeed.item_extra_kwargsc                 O   s   d S r4   r   )r,   r-   r.   r/   r   r   r   r%   z   s   zFeed.get_objectc                 K   s   |  d¡|  d¡dœS )a  
        Return a dictionary to use as extra context if either
        ``self.description_template`` or ``self.item_template`` are used.

        Default implementation preserves the old behavior
        of using {'obj': item, 'site': current_site} as the context.
        r7   Úsite)r0   rX   )Úget)r,   r/   r   r   r   Úget_context_data}   s   zFeed.get_context_datac                 C   s²  t |ƒ}|  d|¡}t|j|| ¡ ƒ}| jd!|  d|¡|  d|¡||  d|¡| jp+tƒ t|j|  d|¡p6|j| ¡ ƒ|  d|¡|  d|¡|  d|¡|  d	|¡|  d
|¡|  d|¡|  d|¡|  d|¡dœ|  	|¡¤Ž}d}| j
dur„zt | j
¡}W n	 tyƒ   Y nw d}| jdur�zt | j¡}W n	 tyœ   Y nw |  d|¡D ]³}| j||||d�}	|dur¹| |	|¡}
n|  d|¡}
|durÊ| |	|¡}n|  d|¡}t|j|  d|¡| ¡ ƒ}|  d|¡}|  d|¡}|durú|  d|¡}|  d|¡}nd }}tƒ }|  d|¡}|�rt|ƒ�rt||ƒ}|  d|¡}|�r't|ƒ�r't||ƒ}|jd!|
|||  d||¡|  d|¡|||||||  d|¡|  d|¡|  d|¡d œ|  |¡¤Ž q£|S )"z“
        Return a feedgenerator.DefaultFeed object, fully populated, for
        this feed. Raise FeedDoesNotExist for invalid parameters.
        ÚlinkÚtitleÚsubtitleÚdescriptionÚfeed_urlÚauthor_nameÚauthor_linkÚauthor_emailÚ
categoriesÚfeed_copyrightÚ	feed_guidÚttlÚstylesheets)r\   r]   r[   r^   Úlanguager_   r`   ra   rb   rc   rd   re   rf   rg   NÚitems)r7   rX   r0   r-   r8   r9   r=   rG   Úitem_author_nameÚitem_author_emailÚitem_author_linkr#   r$   Ú	item_guidÚitem_guid_is_permalinkÚitem_commentsÚitem_categoriesÚitem_copyright)r\   r[   r^   Ú	unique_idÚunique_id_is_permalinkÚ
enclosuresÚpubdateÚupdateddater`   rb   ra   Úcommentsrc   rq   r   )r   rC   r   r   Ú	is_secureÚ	feed_typerh   r   ÚpathrU   Útitle_templater
   Úget_templater	   Údescription_templaterZ   Úrenderr   r   r   Úadd_itemrW   )r,   r0   r-   Úcurrent_siter[   ÚfeedÚ	title_tmpÚdescription_tmpr7   Úcontextr\   r^   rt   r`   rb   ra   Útzru   rv   r   r   r   r&   ‡   s°   



ý







îí
ÿ
ÿÿ
ý

ÿ


ðïzFeed.get_feedr4   )r   r   r    r   ÚDefaultFeedry   r{   r}   rh   r3   r8   r9   r=   rG   rC   rU   rW   r%   rZ   r&   r   r   r   r   r!      s     	

r!   N)F)Úinspectr   r   Údjango.contrib.sites.shortcutsr   Údjango.core.exceptionsr   r   Údjango.httpr   r   Údjango.templater	   r
   Údjango.utilsr   Údjango.utils.encodingr   Údjango.utils.htmlr   Údjango.utils.httpr   Údjango.utils.timezoner   r   r   Údjango.utils.translationr   r   r   r!   r   r   r   r   Ú<module>   s    

