AlkantarClanX12

Your IP : 3.137.178.122


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/nntplib.cpython-310.opt-2.pyc

o

6��f?��	@s<	ddlZddlZddlZddlZddlZzddlZWney&dZYnwdZddlm	Z
ddlmZgd�ZdZ
Gdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZdZdZhd�Zgd�Zddd�ZdZe�dgd��Ze�dgd��Zd d!�Z	d"d#�ZdYd$d%�ZdYd&d'�Z dZd(d)�Z!er�d*d+�Z"Gd,d-�d-�Z#er�Gd.d/�d/e#�Z$e�%d/�e&d0k�r�ddl'Z'e'j(d1d2�Z)e)j*d3d4d5d6d7�e)j*d8d9d:d;d7�e)j*d<d=d>e+d?eefd@�e)j*dAdBdCe+dDd@�e)j*dEdFdGddHdI�e)�,�Z-e-j.Z.e-j�se.d>k�reZ.e#e-j/e.dJ�Z0ne.d>k�r%eZ.e$e-j/e.dJ�Z0e0�1�Z2dKe2v�r9e0�3�e0�4e-j4�\Z5Z6Z7Z8Z9e:dLe9dMe6dNe7dOe8�dPdQ�Z;e<e+e8�e-j=dR�Z7e0�>e7e8�\Z5Z?e?D]-\Z@ZAe	eAdS��BdTdR�dZCe	eAdU�ZDe+eAd�ZEe:dV�Fe@e;eCdW�e;eDdX�eE���qhe0�G�dSdS)[�NFT)�
decode_header)�_GLOBAL_DEFAULT_TIMEOUT)�NNTP�	NNTPError�NNTPReplyError�NNTPTemporaryError�NNTPPermanentError�NNTPProtocolError�
NNTPDataErrorric@seZdZ	dd�ZdS)rcGs>tj|g|�R�z|d|_WdStyd|_YdSw)NrzNo response given)�	Exception�__init__�response�
IndexError)�self�args�r�./opt/alt/python310/lib64/python3.10/nntplib.pyrbs�zNNTPError.__init__N)�__name__�
__module__�__qualname__rrrrrr`src@�eZdZ	dS)rN�rrrrrrrri�rc@r)rNrrrrrrmrrc@r)rNrrrrrrqrrc@r)r	Nrrrrrr	urr	c@r)r
Nrrrrrr
yrr
�wi3>Z222Z101Z282Z230�215Z224Z100Z225Z231Z221�211Z220)�subject�from�datez
message-idZ
references�:bytes�:linesrr )�bytes�lines�
�	GroupInfo)�group�last�first�flag�ArticleInfo)Znumber�
message_idr"cCsL	g}t|�D]\}}t|t�r|�|�|pd��q|�|�qd�|�S)N�ascii�)�_email_decode_header�
isinstancer!�append�decode�join)Z
header_str�parts�v�encrrrr�s

rcCs�	g}|D]0}|ddkr|dd��d�\}}}d|}n|�d�\}}}|��}t�||�}|�|�qt}t|�t|�krDtd��|dt|��|krRtd��|S)Nr�:�z$LIST OVERVIEW.FMT response too shortz*LIST OVERVIEW.FMT redefines default fields)�	partition�lower�_OVERVIEW_FMT_ALTERNATIVES�getr/�_DEFAULT_OVERVIEW_FMT�lenr
)r"�fmt�line�name�_�suffix�defaultsrrr�_parse_overview_fmt�s 
rCcCs�	tt�}g}|D]]}i}|�d�^}}t|�}t|�D]B\}	}
|	t|�kr'q||	}|�d�}|	|krX|sX|d}
|
rL|
dt|
����|
krLtd��|
rV|
t|
�d�nd}
|
|||	<q|�||f�q	|S)N�	r5z: z?OVER/XOVER response doesn't include names of additional headers)	r<r;�split�int�	enumerate�
startswithr8r
r/)r"r=Zdata_process_funcZ
n_defaultsZoverviewr>ZfieldsZarticle_number�tokens�i�tokenZ
field_nameZis_metadata�hrrr�_parse_overview�s(
rMcCs�	|dur|dd�}|dd�}t|dd��}t|dd��}t|dd��}t|dd��}t|dd��}t|dd��}|dkrJ|d7}n|dkrR|d	7}t�||||||�S)
Ni�������������Fi��dil)rF�datetime)�date_str�time_strZhoursZminutesZseconds�yearZmonthZdayrrr�_parse_datetime�s
rXcCsX	t|tj�s
d}nd�|�}|j}|r"|d}d�||�}||fSd�||�}||fS)NZ000000z({0.hour:02d}{0.minute:02d}{0.second:02d}rSz{0:02d}{1.month:02d}{1.day:02d}z{0:04d}{1.month:02d}{1.day:02d})r.rT�formatrW)ZdtZlegacyrV�yrUrrr�_unparse_datetime�s
�r[cCs 	|dur	t��}|j||d�S)N)Zserver_hostname)�sslZ_create_stdlib_contextZwrap_socket)�sock�contextZhostnamerrr�_encrypt_onsr_c@seZdZdZdZeddddefdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�ZeZdd�Zdd�Zdidd�Zdd�Zdjdd�Zd d!�Zdjd"d#�Zdjd$d%�Zd&d'�Zd(d)�Zd*d+�Zdd,�d-d.�Zdd,�d/d0�Zdjdd,�d1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!dd,�d;d<�Z"d=d>�Z#d?d@�Z$djdAdB�Z%dCdD�Z&dEdF�Z'djdGdH�Z(djdd,�dIdJ�Z)djdd,�dKdL�Z*djdd,�dMdN�Z+dOdP�Z,dd,�dQdR�Z-dd,�dSdT�Z.dd,�dUdV�Z/dWdX�Z0dYdZ�Z1d[d\�Z2d]d^�Z3d_d`�Z4dadb�Z5dkdcdd�Z6dedf�Z7e8�rdjdgdh�Z9dSdS)lrzutf-8�surrogateescapeNFcCs~	||_||_|�|�|_d|_z|j�d�|_|�|�|s!|r+|�|||�WdSWdS|jr9|j��|j���)N�rwb)	�host�port�_create_socketr]�file�makefile�
_base_init�login�close)rrbrc�user�password�
readermode�usenetrc�timeoutrrrr8s 
�

z
NNTP.__init__cCs`	d|_|��|_d|_|��d|_|r(d|jvr(|��|js(d|_|��d|_d|_dS)NrF�READER)	�	debugging�_getresp�welcome�_caps�getcapabilities�readermode_afterauth�_setreadermode�tls_on�
authenticated)rrlrrrrg[s
	
zNNTP._base_initcCs|S�Nr�rrrr�	__enter__}szNNTP.__enter__c	sf�fdd�}|�r1zz���WnttfyYnwW|�r&���dSdS|�r0���wwdS)Ncs
t�d�S)Nre)�hasattrrrzrr�<lambda>�s
zNNTP.__exit__.<locals>.<lambda>)�quit�OSError�EOFError�_close)rrZis_connectedrrzr�__exit__�s��
�
��z
NNTP.__exit__cCs<|dur
|s
td��t�d||j|j�t�|j|jf|�S)Nz0Non-blocking socket (timeout=0) is not supportedznntplib.connect)�
ValueError�sys�auditrbrc�socketZcreate_connection)rrnrrrrd�szNNTP._create_socketcCs	|jrtdt|j��|jS)Nz	*welcome*)rp�print�reprrrrzrrr�
getwelcome�szNNTP.getwelcomec	Cs�	|jdurBd|_d|_z|��\}}Wnttfy$i|_Y|jSw||_d|vr6ttt|d��|_d|vrBd�	|d�|_|jS)Nr6ZVERSIONZIMPLEMENTATION� )
rs�nntp_versionZnntp_implementation�capabilitiesrr�max�maprFr1)r�resp�capsrrrrt�s 
	�zNNTP.getcapabilitiescCs	||_dSry)rp)r�levelrrr�set_debuglevel�s
zNNTP.set_debuglevelcCsJ	t�d||�|t}|jdkrtdt|��|j�|�|j��dS)Nznntplib.putliner6z*put*)	r�r��_CRLFrpr�r�re�write�flush�rr>rrr�_putline�sz
NNTP._putlinecCs4	|jrtdt|��|�|j|j�}|�|�dS)Nz*cmd*)rpr�r��encode�encoding�errorsr�r�rrr�_putcmd�szNNTP._putcmdTcCs�	|j�td�}t|�tkrtd��|jdkrtdt|��|s#t�|rC|dd�t	kr5|dd�}|S|dd�t	vrC|dd�}|S)Nr6z
line too longz*get*rQ���)
re�readline�_MAXLINEr<r
rpr�r�r�r�)rZ
strip_crlfr>rrr�_getline�s
�z
NNTP._getlinecCsn	|��}|jrtdt|��|�|j|j�}|dd�}|dkr%t|��|dkr-t|��|dvr5t	|��|S)Nz*resp*r6�4�5Z123)
r�rpr�r�r0r�r�rrr	)rr��crrrrq�sz
NNTP._getrespcCs�	d}zot|ttf�rt|d�}}|��}|dd�tvr"t|��g}|durKdtdf}	|�d�}||vr9n|�	d�rD|dd�}|�
|�q/nd}	|��}||krWn|�	d�rb|dd�}|�|�qNW|ro|��||fS|rz|��ww)N�wb��.s.
r6Fs..)
r.�strr!�openrq�	_LONGRESPrr�r�rHr�r/ri)rreZ
openedFiler�r"Zterminatorsr>�
terminatorrrr�_getlongresp�sH


�

��	�
�zNNTP._getlongrespcCs	|�|�|��Sry)r�rqr�rrr�	_shortcmds
zNNTP._shortcmdcCs	|�|�|�|�Sry�r�r�)rr>rerrr�_longcmds

z
NNTP._longcmdcs0	��|���|�\}}|�fdd�|D�fS)Ncsg|]
}|��j�j��qSr)r0r�r���.0r>rzrr�
<listcomp>+s�z'NNTP._longcmdstring.<locals>.<listcomp>r�)rr>rer��listrrzr�_longcmdstring$s
�zNNTP._longcmdstringcCsb	z|jWStyYnwz	|�d�\}}Wnty'tdd�}Ynwt|�}||_|S)NzLIST OVERVIEW.FMT)Z_cachedoverviewfmt�AttributeErrorr�rr;rC)rr�r"r=rrr�_getoverviewfmt.s��zNNTP._getoverviewfmtcCsdd�|D�S)NcSsg|]}t|����qSr)r$rEr�rrrr�Asz#NNTP._grouplist.<locals>.<listcomp>r)rr"rrr�
_grouplist?szNNTP._grouplistcCs:	i}|�d�\}}|D]}|��^}}|||<q||fS)NZCAPABILITIES)r�rE)rr�r�r"r>r?rIrrrr�Cs
zNNTP.capabilities)recCsd	t|tjtjf�std�|jj���t||jdk�\}}d�||�}|�	||�\}}||�
|�fS)N�Athe date parameter must be a date or datetime object, not '{:40}'rNzNEWGROUPS {0} {1})r.rTr�	TypeErrorrY�	__class__rr[r�r�r�)rrrerUrV�cmdr�r"rrr�	newgroupsQs
�zNNTP.newgroupscCsT	t|tjtjf�std�|jj���t||jdk�\}}d�|||�}|�	||�S)Nr�rNzNEWNEWS {0} {1} {2})
r.rTrr�rYr�rr[r�r�)rr%rrerUrVr�rrr�newnewsas
�zNNTP.newnewscCs6	|dur
d|}nd}|�||�\}}||�|�fS)NzLIST ACTIVE ZLIST)r�r�)r�
group_patternre�commandr�r"rrrr�qs
z	NNTP.listcCs�t�d�}|�d|�\}}|�d�s|�d|�\}}i}|D]}|�|���}|r=|�dd�\}	}
|s9|
S|
||	<q |rD||fSdS)Nz^(?P<group>[^ 	]+)[ 	]+(.*)$zLIST NEWSGROUPS rzXGTITLE r6rNr,)�re�compiler�rH�search�stripr%)rr�Z
return_allZline_patr�r"�groupsZraw_line�matchr?Zdescrrr�_getdescriptions�s 

�zNNTP._getdescriptionscC�	|�|d�S)NF�r�)rr%rrr�description�s
zNNTP.descriptioncCr�)NTr�)rr�rrr�descriptions�szNNTP.descriptionscCs�	|�d|�}|�d�st|��|��}d}}}t|�}|dkrA|d}|dkrA|d}|dkrA|d}|dkrA|d��}|t|�t|�t|�|fS)NzGROUP rrr6rNr�rO)r�rHrrEr<r8rF)rr?r��words�countr'r&�nrrrr%�s 	
z
NNTP.groupcC�	|�d|�S)NZHELP)r�)rrerrr�help�sz	NNTP.helpcCs:	|�d�s
t|��|��}t|d�}|d}|||fS)NZ22r6rN)rHrrErF)rr�r��art_numr*rrr�
_statparse�s

zNNTP._statparsecCs	|�|�}|�|�Sry)r�r�)rr>r�rrr�_statcmd�s

z
NNTP._statcmdcCs 	|r|�d�|��S|�d�S)NzSTAT {0}ZSTAT)r�rY)r�message_specrrr�stat�s
z	NNTP.statcC�	|�d�S)NZNEXT�r�rzrrr�next��
z	NNTP.nextcCr�)NZLASTr�rzrrrr&�r�z	NNTP.lastcCs2	|�||�\}}|�|�\}}}|t|||�fSry)r�r�r))rr>rer�r"r�r*rrr�_artcmd�szNNTP._artcmdcC�&	|durd�|�}nd}|�||�S)NzHEAD {0}ZHEAD�rYr��rr�rer�rrr�head��
z	NNTP.headcCr�)NzBODY {0}ZBODYr�r�rrr�bodyr�z	NNTP.bodycCr�)NzARTICLE {0}ZARTICLEr�r�rrr�articler�zNNTP.articlecCr�)NZSLAVE)r�rzrrr�slave!s
z
NNTP.slavecsF	t�d��|�d�||�|�\}}�fdd��|�fdd�|D�fS)Nz^([0-9]+) ?(.*)
?zXHDR {0} {1}cs��|�}|r
|�dd�S|S)Nr6rN)r�r%)r>�m)�patrr�
remove_number2s
z NNTP.xhdr.<locals>.remove_numbercsg|]}�|��qSrrr�)r�rrr�5szNNTP.xhdr.<locals>.<listcomp>)r�r�r�rY)rZhdrr�rer�r"r)r�r�r�xhdr's

z	NNTP.xhdrcCs0	|�d�||�|�\}}|��}|t||�fS)Nz
XOVER {0}-{1})r�rYr�rM)r�start�endrer�r"r=rrr�xover7s�z
NNTP.xoverc	Csz	d|jvrdnd}t|ttf�r |\}}|d�||pd�7}n
|dur*|d|}|�||�\}}|��}|t||�fS)NZOVERZXOVERz {0}-{1}r,r�)rsr.�tupler�rYr�r�rM)	rr�rer�r�r�r�r"r=rrr�overEsz	NNTP.overcCsd	|�d�}|�d�st|��|��}t|�dkrt|��|d}t|�dkr+t|��|t|d�fS)NZDATEZ111rNr6�)r�rHrrEr<r
rX)rr��elemrrrrr`s

z	NNTP.datecCs�|�|�}|�d�st|��t|ttf�r|��}|D]}|�t�s)|�	d�t}|�d�r2d|}|j
�|�q|j
�d�|j
��|�
�S)N�3r#r�s.
)r�rHrr.r!�	bytearray�
splitlines�endswithr��rstriprer�r�rq)rr��fr�r>rrr�_postqs




z
NNTP._postcCr�)NZPOST)r�)r�datarrr�post�sz	NNTP.postcCs	|�d�|�|�S)Nz	IHAVE {0})r�rY)rr*r�rrr�ihave�sz
NNTP.ihavecCsBz|jr|j��|`W|j��dSW|j��dS|j��wry)rerir]rzrrrr��s
�zNNTP._closecCs&	z|�d�}W|��|S|��w)NZQUIT)r�r�)rr�rrrr~�s
�z	NNTP.quitcCs�|jrtd��|s|std��z|r,|s,ddl}|��}|�|j�}|r,|d}|d}Wn	ty6Ynw|s;dS|�d|�}|�d�r]|sMt|��|�d|�}|�d�s]t	|��d|_
|��|jryd	|j
vr{|�
�d|_
|��dSdSdS)
NzAlready logged in.z7At least one of `user` and `usenetrc` must be specifiedrrNzauthinfo user Z381zauthinfo pass Z281ro)rxr��netrcZauthenticatorsrbrr�rHrrrsrtrurv)rrjrkrmr�ZcredentialsZauthr�rrrrh�sD���

�z
NNTP.loginc
Csbz	|�d�|_WdStyYdSty0}z|j�d�r$d|_n�WYd}~dSd}~ww)Nzmode readerZ480T)r�rrrrr
rHru)r�errrrv�s���zNNTP._setreadermodecCs|	|jrtd��|jrtd��|�d�}|�d�r:|j��t|j||j	�|_|j�
d�|_d|_d|_|��dSt
d��)NzTLS is already enabled.z+TLS cannot be started after authentication.�STARTTLSZ382raTzTLS failed to start.)rwr�rxr�rHrerir_r]rbrfrsrtr)rr^r�rrr�starttls�s


z
NNTP.starttls)Try)NNT):rrrr�r��	NNTP_PORTrrrgr{r�rdr�rtr��debugr�r�r�rqr�r�r�r�r�r�r�r�r�r�r�r�r�r%r�r�r�r�r�r&r�r�r�r�r�r�r�r�rr�r�r�r�r~rhrv�	_have_sslr�rrrrr(st

�#"		

.







	
	)
�rcs8eZdZedddddef�fdd�	Z�fdd�Z�ZS)�NNTP_SSLNFc			s$	||_t��|||||||�dSry)�ssl_context�superr)	rrbrcrjrkr�rlrmrn�r�rrr�s
�zNNTP_SSL.__init__cs4t��|�}zt||j|j�}W|S|���ry)r�rdr_r�rbri)rrnr]r�rrrds�zNNTP_SSL._create_socket)rrr�
NNTP_SSL_PORTrrrd�
__classcell__rrr�rr��s�r��__main__zJ        nntplib built-in demo - display the latest articles in a newsgroup)r�z-gz--groupzgmane.comp.python.generalz3group to fetch messages from (default: %(default)s))�defaultr�z-sz--serverz
news.gmane.ioz+NNTP server hostname (default: %(default)s)z-pz--portr�z#NNTP port number (default: %s / %s))r�typer�z-nz
--nb-articles�
z2number of articles to fetch (default: %(default)s)z-Sz--ssl�
store_truezuse NNTP over SSL)�actionrr�)rbrcr�ZGroupZhaszarticles, range�tocCs$t|�|kr|d|d�d}|S)NrOz...)r<)�sZlimrrr�cut3sr
r6r�<rz{:7} {:20} {:42} ({})��*ry)F)Hr�r��collectionsrTr�r\�ImportErrorr�Zemail.headerrr-r�__all__r�rrrrrr	r
r�rr�r;r9r��
namedtupler$r)rCrMrXr[r_rr�r/r�argparse�ArgumentParser�parser�add_argumentrF�
parse_argsrrcZserverr	rtr�r�r%r�r�r'r&r?r�r
r�Znb_articlesr�Z	overviewsZartnumr�rEZauthorrr"rYr~rrrr�<module>s�A�
	���


S


�
�
���



��