a
    ‘´íjêB  ã                   @   s@   d dl Z ddlmZ ddlmZ ddlmZ G dd„ deƒZdS )é    Né   )Ú_parse_date)Úmake_safe_absolute_uri)ÚFeedParserDictc                   @   sà  e Zd ZdZddddddddddddddœZdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	e	Z
dd„ Zdd„ Zdd„ ZeZdd„ ZeZdd„ ZeZdd„ ZeZdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ ZeZeZd,d-„ Z e Z!e Z"d.d/„ Z#d0d1„ Z$d2d3„ Z%e%Z&d4d5„ Z'e'Z(d6d7„ Z)e)Z*d8d9„ Z+e+Z,d:d;„ Z-e-Z.d<d=„ Z/e/Z0d>d?„ Z1d@dA„ Z2dBdC„ Z3dDdE„ Z4dFdG„ Z5e5Z6e5Z7dHdI„ Z8e8Z9e8Z:dJdK„ Z;e;Z<e;Z=dLdM„ Z>e>Z?e>Z@dNdO„ ZAdPdQ„ ZBdRdS„ ZCdTdU„ ZDdVdW„ ZEeEZFdXdY„ ZGeGZHdZd[„ ZId\d]„ ZJd^d_„ ZKd`da„ ZLeLZMdbdc„ ZNeNZOddde„ ZPdfdg„ ZQdhdi„ ZRdjdk„ ZSdldm„ ZTeTZUdndo„ ZVeVZWdpdq„ ZXeXZYdrds„ ZZdtdu„ Z[dvdw„ Z\dxdy„ Z]dzd{„ Z^d|d}„ Z_d~d„ Z`d€d�„ Zad‚dƒ„ ZbebZcd„d…„ ZdedZed†d‡„ ZfefZgefZhefZiefZjdˆd‰„ ZkdŠd‹„ ZldŒS )�Ú	NamespacezêSupport for the Atom, RSS, RDF, and CDF feed formats.

    The feed formats all share common elements, some of which have conflicting
    interpretations. For simplicity, all of the base feed format support is
    collected here.
    Ú )r   zhttp://backend.userland.com/rssz%http://blogs.law.harvard.edu/tech/rsszhttp://purl.org/rss/1.0/z&http://my.netscape.com/rdf/simple/0.9/zhttp://example.com/newformat#zhttp://example.com/nechozhttp://purl.org/echo/zuri/of/echo/namespace#zhttp://purl.org/pie/zhttp://purl.org/atom/ns#zhttp://www.w3.org/2005/Atomz'http://purl.org/rss/1.0/modules/rss091#c                 C   s^   dddddœ}| j r | j  d¡sZ| dd¡}| |¡}|rB|| _ n| d	¡rTd
| _ nd| _ d S )NZrss091uZrss092Zrss093Zrss094)z0.91z0.92z0.93z0.94ZrssÚversionr   z2.Zrss20)r   Ú
startswithÚget©ÚselfÚattrs_dZ
versionmapZattr_versionr   © r   úZ/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/feedparser/namespaces/_base.pyÚ
_start_rss<   s    ü


zNamespace._start_rssc                 C   s   d| _ |  |¡ d S )Né   )ÚinfeedÚ_cdf_common©r   r   r   r   r   Ú_start_channelQ   s    zNamespace._start_channelc                 C   s\   d|v r,|   i ¡ |d | jd d< |  ¡  d|v rX|  i ¡ |d | jd d< |  ¡  d S )NZlastmodéÿÿÿÿÚhref)Ú_start_modifiedZelementstackÚ_end_modifiedÚ_start_linkÚ	_end_linkr   r   r   r   r   U   s    

zNamespace._cdf_commonc                 C   sB   d| _ ddddœ}| js>| d¡}| |¡}|r8|| _nd| _d S )Nr   Zatom01Zatom02Zatom03)z0.1z0.2z0.3r   Zatom)r   r   r
   r   r   r   r   Ú_start_feed_   s    þ

zNamespace._start_feedc                 C   s
   d| _ d S )Nr   )r   ©r   r   r   r   Ú_end_channell   s    zNamespace._end_channelc                 C   s8   |   ¡ }| js| dtƒ ¡ d| _d| _|  dd¡ d S )NÚimager   r   r   )Ú_get_contextÚinentryÚ
setdefaultr   ÚinimageÚtitle_depthÚpush©r   r   Úcontextr   r   r   Ú_start_imagep   s    zNamespace._start_imagec                 C   s   |   d¡ d| _d S )Nr   r   )Úpopr#   r   r   r   r   Ú
_end_imagex   s    
zNamespace._end_imagec                 C   s2   |   ¡ }| dtƒ ¡ d| _d| _|  dd¡ d S )NÚ	textinputr   r   r   )r    r"   r   Úintextinputr$   r%   r&   r   r   r   Ú_start_textinput|   s
    zNamespace._start_textinputc                 C   s   |   d¡ d| _d S )Nr+   r   )r)   r,   r   r   r   r   Ú_end_textinput„   s    
zNamespace._end_textinputc                 C   s:   d| _ |  dd¡ |  ¡ }| dg ¡ |d  tƒ ¡ d S )Nr   ÚauthorZauthors)Úinauthorr%   r    r"   Úappendr   r&   r   r   r   Ú_start_author‰   s
    zNamespace._start_authorc                 C   s   |   d¡ d| _|  ¡  d S )Nr/   r   )r)   r0   Ú_sync_author_detailr   r   r   r   Ú_end_author’   s    
zNamespace._end_authorc                 C   s:   d| _ |  ¡ }| dg ¡ |d  tƒ ¡ |  dd¡ d S )Nr   ZcontributorsÚcontributorr   )Úincontributorr    r"   r1   r   r%   r&   r   r   r   Ú_start_contributor˜   s
    zNamespace._start_contributorc                 C   s   |   d¡ d| _d S )Nr5   r   )r)   r6   r   r   r   r   Ú_end_contributorŸ   s    
zNamespace._end_contributorc                 C   s   |   dd¡ d S )NÚnamer   ©r%   r   r   r   r   Ú_start_name£   s    zNamespace._start_namec                 C   sb   |   d¡}| jr |  d|d¡ n>| jr4|  d|¡ n*| jrH|  d|¡ n| jr^|  ¡ }||d< d S )Nr9   Ú	publisher)r)   ÚinpublisherÚ_save_authorr0   r6   Ú_save_contributorr,   r    ©r   Úvaluer'   r   r   r   Ú	_end_name¦   s    
zNamespace._end_namec                 C   s   |   dd¡ d S ©NÚwidthr   r:   r   r   r   r   Ú_start_width²   s    zNamespace._start_widthc                 C   sH   |   d¡}zt|ƒ}W n ty,   d}Y n0 | jrD|  ¡ }||d< d S rC   ©r)   ÚintÚ
ValueErrorr#   r    r@   r   r   r   Ú
_end_widthµ   s    

zNamespace._end_widthc                 C   s   |   dd¡ d S ©NÚheightr   r:   r   r   r   r   Ú_start_height¿   s    zNamespace._start_heightc                 C   sH   |   d¡}zt|ƒ}W n ty,   d}Y n0 | jrD|  ¡ }||d< d S rJ   rF   r@   r   r   r   Ú_end_heightÂ   s    

zNamespace._end_heightc                 C   s   |   dd¡ d S )Nr   r   r:   r   r   r   r   Ú
_start_urlÌ   s    zNamespace._start_urlc                 C   s4   |   d¡}| jr|  d|¡ n| jr0|  d|¡ d S )Nr   )r)   r0   r>   r6   r?   ©r   rA   r   r   r   Ú_end_urlÑ   s
    
zNamespace._end_urlc                 C   s   |   dd¡ d S )NÚemailr   r:   r   r   r   r   Ú_start_emailÚ   s    zNamespace._start_emailc                 C   sJ   |   d¡}| jr |  d|d¡ n&| jr4|  d|¡ n| jrF|  d|¡ d S )NrQ   r<   )r)   r=   r>   r0   r6   r?   rO   r   r   r   Ú
_end_emailÝ   s    
zNamespace._end_emailc                 C   s   |   d|dd¡ d S )NÚsubtitleú
text/plainr   ©Úpush_contentr   r   r   r   Ú_start_subtitleæ   s    zNamespace._start_subtitlec                 C   s   |   d¡ d S )NrT   ©Úpop_contentr   r   r   r   Ú_end_subtitleê   s    zNamespace._end_subtitlec                 C   s   |   d|dd¡ d S )NÚrightsrU   r   rV   r   r   r   r   Ú_start_rightsî   s    zNamespace._start_rightsc                 C   s   |   d¡ d S )Nr\   rY   r   r   r   r   Ú_end_rightsò   s    zNamespace._end_rightsc                 C   sZ   | j  tƒ ¡ |  dd¡ d| _d| _d| _|  |d¡}|rL|  ¡ }||d< |  	|¡ d S )NÚitemr   r   r   z	rdf:aboutÚid)
Úentriesr1   r   r%   r!   Ú
guidislinkr$   Z_get_attributer    r   )r   r   r`   r'   r   r   r   Ú_start_itemö   s    zNamespace._start_itemc                 C   s   |   d¡ d| _d| _d S )Nr_   r   )r)   r!   Ú
hasContentr   r   r   r   Ú	_end_item  s    
zNamespace._end_itemc                 C   s   |   dd¡ d S )NÚlanguager   r:   r   r   r   r   Ú_start_language	  s    zNamespace._start_languagec                 C   s   |   d¡| _d S )Nrf   )r)   Úlangr   r   r   r   Ú_end_language  s    zNamespace._end_languagec                 C   s   |   dd¡ d S )Nr<   r   r:   r   r   r   r   Ú_start_webmaster  s    zNamespace._start_webmasterc                 C   s   |   d¡ |  d¡ d S )Nr<   )r)   r3   r   r   r   r   Ú_end_webmaster  s    
zNamespace._end_webmasterc                 C   s   |   dd¡ d S )NÚ	publishedr   r:   r   r   r   r   Ú_start_published  s    zNamespace._start_publishedc                 C   s"   |   d¡}| jdt|ƒdd� d S )Nrl   Zpublished_parsedT©Ú	overwrite©r)   Ú_saver   rO   r   r   r   Ú_end_published  s    
zNamespace._end_publishedc                 C   s   |   dd¡ d S )NÚupdatedr   r:   r   r   r   r   Ú_start_updated!  s    zNamespace._start_updatedc                 C   s&   |   d¡}t|ƒ}| jd|dd� d S )Nrs   Zupdated_parsedTrn   )r)   r   rq   )r   rA   Zparsed_valuer   r   r   Ú_end_updated&  s    
zNamespace._end_updatedc                 C   s   |   dd¡ d S )NÚcreatedr   r:   r   r   r   r   Ú_start_created-  s    zNamespace._start_createdc                 C   s"   |   d¡}| jdt|ƒdd� d S )Nrv   Zcreated_parsedTrn   rp   rO   r   r   r   Ú_end_created0  s    
zNamespace._end_createdc                 C   s   |   dd¡ d S )NÚexpiredr   r:   r   r   r   r   Ú_start_expirationdate4  s    zNamespace._start_expirationdatec                 C   s   | j dt|  d¡ƒdd� d S )NZexpired_parsedry   Trn   )rq   r   r)   r   r   r   r   Ú_end_expirationdate7  s    zNamespace._end_expirationdatec                 C   sD   |  d¡}|  d|  d¡¡}|  d¡}|  |||¡ |  dd¡ d S )NÚtermÚschemeÚdomainÚlabelÚcategoryr   )r
   Ú_add_tagr%   )r   r   r|   r}   r   r   r   r   Ú_start_category:  s
    

zNamespace._start_categoryc                 C   sZ   |   d¡}|sd S |  ¡ }|d }|rHt|ƒrH|d d sH||d d< n|  |d d ¡ d S )Nr€   Útagsr   r|   )r)   r    Úlenr�   )r   rA   r'   rƒ   r   r   r   Ú_end_categoryB  s    
zNamespace._end_categoryc                 C   s   t |ƒ|  ¡ d< d S )NÚcloud)r   r    r   r   r   r   Ú_start_cloudN  s    zNamespace._start_cloudc                 C   sä   |  dd¡ |d dkr&|  dd¡ n|  dd¡ |  ¡ }|  |¡}d|v r^|  |d ¡|d< | jpn| jpn| j}|  dg ¡ | jrˆ| jsš|d  t	|ƒ¡ d|v rÔ| 
d¡dkrà|  | 
d¡¡| jv rà|d |d	< n|  d	|¡ d S )
NÚrelÚ	alternater   Útypezapplication/atom+xmlú	text/htmlr   ÚlinksÚlink)r"   r    Ú_enforce_hrefÚresolve_urir   r!   Úinsourcer#   r1   r   r
   Úmap_content_typeÚ
html_typesr%   )r   r   r'   Zexpecting_textr   r   r   r   Q  s&    
ÿþzNamespace._start_linkc                 C   s   |   d¡ d S )Nr�   )r)   r   r   r   r   r   h  s    zNamespace._end_linkc                 C   s"   |  dd¡dk| _|  dd¡ d S )NZispermalinkÚtruer`   r   )r
   rb   r%   r   r   r   r   Ú_start_guidk  s    zNamespace._start_guidc                 C   s:   |   d¡}|  d| jo d|  ¡ v¡ | jr6|  d|¡ d S )Nr`   rb   r�   )r)   rq   rb   r    rO   r   r   r   Ú	_end_guidp  s    
zNamespace._end_guidc                 C   s<   | j r|  dt| ¡ ƒ¡S |  d|d| jp4| jp4| j¡ d S )NÚtitlerU   )ÚsvgOKZunknown_starttagÚlistÚitemsrW   r   r!   r�   r   r   r   r   Ú_start_titley  s    zNamespace._start_titlec                 C   s(   | j r
d S |  d¡}|sd S | j| _d S )Nr–   )r—   rZ   Údepthr$   rO   r   r   r   Ú
_end_title~  s    
zNamespace._end_titlec                 C   sJ   |   ¡ }d|v r(| js(d| _|  |¡ n|  d|d| jpB| jpB| j¡ d S )NÚsummaryÚcontentÚdescriptionr‹   )r    rd   Ú_summaryKeyÚ_start_contentrW   r   r!   r�   r&   r   r   r   Ú_start_description†  s
    zNamespace._start_descriptionc                 C   s"   |   d|d| jp| jp| j¡ d S )NrŸ   rU   )rW   r   r!   r�   r   r   r   r   Ú_start_abstractŽ  s    zNamespace._start_abstractc                 C   s(   | j dkr|  ¡  n
|  d¡ d | _ d S )Nrž   rŸ   ©r    Ú_end_contentrZ   r   r   r   r   Ú_end_description‘  s    


zNamespace._end_descriptionc                 C   s   |   d|dd¡ d S )NÚinforU   r   rV   r   r   r   r   Ú_start_info™  s    zNamespace._start_infoc                 C   s   |   d¡ d S )Nr§   rY   r   r   r   r   Ú	_end_info�  s    zNamespace._end_infoc                 C   sH   |r(|   |¡}d|v r(|  |d ¡|d< t|ƒ|  ¡ d< |  dd¡ d S )Nr   Úgenerator_detailÚ	generatorr   )rŽ   r�   r   r    r%   r   r   r   r   Ú_start_generator¡  s    
zNamespace._start_generatorc                 C   s*   |   d¡}|  ¡ }d|v r&||d d< d S )Nr«   rª   r9   )r)   r    r@   r   r   r   Ú_end_generator©  s    
zNamespace._end_generatorc                 C   sD   |   ¡ }d|v r(| js(d| _|  |¡ nd| _|  | j|dd¡ d S )Nr�   rž   rU   r   )r    rd   r    r¡   rW   r&   r   r   r   Ú_start_summary¯  s    zNamespace._start_summaryc                 C   s.   | j dkr|  ¡  n|  | j p d¡ d | _ d S )Nrž   r�   r¤   r   r   r   r   Ú_end_summary¸  s    

zNamespace._end_summaryc                 C   s4   |   |¡}|  ¡ }d|d< | dg ¡ t|ƒ¡ d S )NZ	enclosurerˆ   rŒ   )rŽ   r    r"   r1   r   r&   r   r   r   Ú_start_enclosure¿  s    
zNamespace._start_enclosurec                 C   s2   d|v r|d | j d< |  dd¡ d| _d| _d S )NÚurlr   Úsourcer   r   )Ú
sourcedatar%   r�   r$   r   r   r   r   Ú_start_sourceÅ  s
    zNamespace._start_sourcec                 C   s@   d| _ |  d¡}|r|| jd< t | j¡|  ¡ d< | j ¡  d S )Nr   r²   r–   )r�   r)   r³   ÚcopyÚdeepcopyr    ÚclearrO   r   r   r   Ú_end_sourceÍ  s    

zNamespace._end_sourcec                 C   s>   d| _ |  d|dd¡ | d¡}|r.|| jd< |  dd¡ d S )Nr   rž   rU   Úsrc)rd   rW   r
   Úcontentparamsr%   )r   r   r¹   r   r   r   r¡   Õ  s    

zNamespace._start_contentc                 C   s   |   d|dd¡ d S )Nrž   zapplication/xhtml+xmlr   rV   r   r   r   r   Ú_start_bodyÝ  s    zNamespace._start_bodyc                 C   s   d| _ |  d|dd¡ d S )Nr   rž   r‹   )rd   rW   r   r   r   r   Ú_start_content_encodedá  s    z Namespace._start_content_encodedc                 C   s<   |   | j d¡¡dh| jB v }|  d¡}|r8|  d|¡ d S )NrŠ   rU   rž   r�   )r‘   rº   r
   r’   rZ   rq   )r   ZcopyToSummaryrA   r   r   r   r¥   æ  s    
zNamespace._end_contentc                 C   s   |   dd¡ d S )NÚnewlocationr   r:   r   r   r   r   Ú_start_newlocationñ  s    zNamespace._start_newlocationc                 C   s8   |   d¡}|  ¡ }|| jur d S t| j| ¡ ƒ|d< d S )Nr½   )r)   r    Zfeeddatar   ZbaseuriÚstrip)r   r±   r'   r   r   r   Ú_end_newlocationô  s
    

zNamespace._end_newlocationN)mÚ__name__Ú
__module__Ú__qualname__Ú__doc__Zsupported_namespacesr   r   r   r   r   Z	_end_feedr(   r*   r-   Z_start_textInputr.   Z_end_textInputr2   Z_start_managingeditorr4   Z_end_managingeditorr7   r8   r;   rB   rE   rI   rL   rM   rN   Z_start_homepageZ
_start_urirP   Z_end_homepageZ_end_urirR   rS   rX   Z_start_tagliner[   Z_end_tagliner]   Z_start_copyrightr^   Z_end_copyrightrc   Z_start_entryre   Z
_end_entryrg   ri   rj   rk   rm   Z_start_issuedZ_start_pubdaterr   Z_end_issuedZ_end_pubdatert   r   Z_start_lastbuilddateru   r   Z_end_lastbuilddaterw   rx   rz   r{   r‚   Z_start_keywordsr…   Z_end_keywordsr‡   r   r   r”   Z	_start_idr•   Z_end_idrš   rœ   r¢   r£   r¦   Z_end_abstractr¨   Z!_start_feedburner_browserfriendlyr©   Z_end_feedburner_browserfriendlyr¬   r­   r®   r¯   r°   r´   r¸   r¡   r»   Z_start_xhtml_bodyr¼   Z_start_fullitemr¥   Z	_end_bodyZ_end_xhtml_bodyZ_end_content_encodedZ_end_fullitemr¾   rÀ   r   r   r   r   r   $   sî   ó


	
	r   )	rµ   Z	datetimesr   Úurlsr   Úutilr   Úobjectr   r   r   r   r   Ú<module>   s   