AlkantarClanX12

Your IP : 18.227.0.255


Current Path : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/nntplib.cpython-38.opt-2.pyc

U

i�f���@s�ddlZddlZddlZddlZddlZddlZzddlZWnek
rTdZYnXdZddl	m
ZddlmZdddd	d
ddd
gZ
dZGdd�de�ZGdd�de�ZGdd	�d	e�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZdZdZdddddddddd d!d"hZd#d$d%d&d'd(d)gZd(d)d*�Zd+Ze�d,d-d.d/d0g�Ze�d1d2d3d4g�Zd5d
�Z
d6d7�Zdld8d9�Z dmd:d;�Z!dnd<d=�Z"e�r�d>d?�Z#Gd@dA�dA�Z$GdBd�de$�Z%e�r�GdCdD�dDe$�Z&e
�'dD�e(dEk�r�ddl)Z)e)j*dFdG�Z+e+j,dHdIdJdKdL�e+j,dMdNdOdPdL�e+j,dQdRdSe-dTeefdU�e+j,dVdWdXe-dYdU�e+j,dZd[d\dd]d^�e+�.�Z/e/j0Z0e/j�s�e0dSk�rxeZ0e%e/j1e0d_�Z2ne0dSk�r�eZ0e&e/j1e0d_�Z2e2�3�Z4d`e4k�r�e2�5�e2�6e/j6�\Z7Z8Z9Z:Z;e<dae;dbe8dce9dde:�dedf�Z=e>e-e:�e/j?dg�Z9e2�@e9e:�\Z7ZAeAD]Z\ZBZCe
eCd$��Ddhdg�dZEe
eCd#�ZFe-eCd)�ZGe<di�HeBe=eEdj�e=eFdk�eG���qe2�I�dS)o�NFT)�
decode_header)�_GLOBAL_DEFAULT_TIMEOUT�NNTP�	NNTPError�NNTPReplyError�NNTPTemporaryError�NNTPPermanentError�NNTPProtocolError�
NNTPDataErrorric@seZdZdd�ZdS)rcGs>tj|f|��z|d|_Wntk
r8d|_YnXdS)NrzNo response given)�	Exception�__init__�response�
IndexError)�self�args�r�,/opt/alt/python38/lib64/python3.8/nntplib.pyrcs
zNNTPError.__init__N)�__name__�
__module__�__qualname__rrrrrrasc@seZdZdS)rN�rrrrrrrrjsc@seZdZdS)rNrrrrrrnsc@seZdZdS)rNrrrrrrrsc@seZdZdS)r	Nrrrrrr	vsc@seZdZdS)r
Nrrrrrr
zs�wi3Z100Z101�211�215Z220Z221Z222Z224Z225Z230Z231Z282�subject�from�datez
message-idZ
referencesz:bytesz:lines)�bytes�lines�
�	GroupInfo�group�last�first�flag�ArticleInfoZnumber�
message_idrcCsJg}t|�D]2\}}t|t�r4|�|�|p,d��q|�|�qd�|�S)N�ascii�)�_email_decode_header�
isinstancer�append�decode�join)Z
header_str�parts�v�encrrrr�s
cCs�g}|D]`}|ddkr:|dd��d�\}}}d|}n|�d�\}}}|��}t�||�}|�|�qt}t|�t|�kr�td��|dt|��|kr�td��|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
r?cCs�tt�}g}|D]�}i}|�d�^}}t|�}t|�D]�\}	}
|	t|�krLq6||	}|�d�}|	|kr�|s�|d}
|
r�|
dt|
����|
kr�td��|
r�|
t|
�d�nd}
|
|||	<q6|�||f�q|S)N�	r1z: z?OVER/XOVER response doesn't include names of additional headers)	r8r7�split�int�	enumerate�
startswithr4r
r+)rr9Zdata_process_funcZ
n_defaultsZoverviewr:ZfieldsZarticle_number�tokens�i�tokenZ
field_nameZis_metadata�hrrr�_parse_overview�s&
rIcCs�|dkr |dd�}|dd�}t|dd��}t|dd��}t|dd��}t|dd��}t|dd��}t|dd��}|dkr�|d7}n|dkr�|d	7}t�||||||�S)
Ni�������������Fi��dil)rB�datetime)�date_str�time_strZhoursZminutesZseconds�yearZmonthZdayrrr�_parse_datetime�s
rTcCsPt|tj�sd}n
d�|�}|j}|r<|d}d�||�}nd�||�}||fS)NZ000000z({0.hour:02d}{0.minute:02d}{0.second:02d}rOz{0:02d}{1.month:02d}{1.day:02d}z{0:04d}{1.month:02d}{1.day:02d})r*rP�formatrS)ZdtZlegacyrR�yrQrrr�_unparse_datetime�s

rWcCs|dkrt��}|j||d�S)N)Zserver_hostname)�sslZ_create_stdlib_contextZwrap_socket)�sock�contextZhostnamerrr�_encrypt_onsr[c@seZdZdZdZdefdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�ZeZdd�Z
dd�Zdhdd�Zdd�Zdidd�Zdd�Zdjdd�Zdkdd �Zd!d"�Zd#d$�Zd%d&�Zdd'�d(d)�Zdd'�d*d+�Zdldd'�d,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zdd'�d6d7�Zd8d9�Z d:d;�Z!dmd<d=�Z"d>d?�Z#d@dA�Z$dndBdC�Z%dodd'�dDdE�Z&dpdd'�dFdG�Z'dqdd'�dHdI�Z(dJdK�Z)dd'�dLdM�Z*dd'�dNdO�Z+dd'�dPdQ�Z,dd'�dRdS�Z-dTdU�Z.dVdW�Z/dXdY�Z0dZd[�Z1d\d]�Z2d^d_�Z3d`da�Z4drdbdc�Z5ddde�Z6e7�rdsdfdg�Z8dS)t�	_NNTPBasezutf-8�surrogateescapeNcCsj||_||_d|_|��|_d|_|��d|_|rZd|jkrZ|��|jsZd|_|��d|_	d|_
dS)NrF�READER)�host�file�	debugging�_getresp�welcome�_caps�getcapabilities�readermode_afterauth�_setreadermode�tls_on�
authenticated)rr`r_�
readermode�timeoutrrrr9s
	z_NNTPBase.__init__cCs|S�Nr�rrrr�	__enter__hsz_NNTPBase.__enter__c	sR�fdd�}|�rNz*z���Wnttfk
r8YnXW5|�rL���XdS)Ncs
t�d�S)Nr`)�hasattrrrmrr�<lambda>l�z$_NNTPBase.__exit__.<locals>.<lambda>)�_close�quit�OSError�EOFError)rrZis_connectedrrmr�__exit__ks
z_NNTPBase.__exit__cCs|jrtdt|j��|jS)Nz	*welcome*)ra�print�reprrcrmrrr�
getwelcomevsz_NNTPBase.getwelcomec	Cs�|jdkr�d|_d|_z|��\}}Wnttfk
rDi|_Yn<X||_d|krhttt|d��|_d|kr�d�	|d�|_|jS)Nr2ZVERSIONZIMPLEMENTATION� )
rd�nntp_versionZnntp_implementation�capabilitiesrr�max�maprBr-)r�resp�capsrrrres
z_NNTPBase.getcapabilitiescCs
||_dSrl)ra)r�levelrrr�set_debuglevel�sz_NNTPBase.set_debuglevelcCsHt�d||�|t}|jdkr.tdt|��|j�|�|j��dS)Nznntplib.putliner2z*put*)	�sys�audit�_CRLFrarwrxr`�write�flush�rr:rrr�_putline�s
z_NNTPBase._putlinecCs2|jrtdt|��|�|j|j�}|�|�dS)Nz*cmd*)rarwrx�encode�encoding�errorsr�r�rrr�_putcmd�sz_NNTPBase._putcmdTcCs�|j�td�}t|�tkr$td��|jdkr<tdt|��|sDt�|r�|dd�t	krf|dd�}n|dd�t	kr�|dd�}|S)Nr2z
line too longz*get*rM���)
r`�readline�_MAXLINEr8r
rarwrxrur�)rZ
strip_crlfr:rrr�_getline�s
z_NNTPBase._getlinecCsl|��}|jrtdt|��|�|j|j�}|dd�}|dkrHt|��|dkrXt|��|dkrht	|��|S)Nz*resp*r2�4�5Z123)
r�rarwrxr,r�r�rrr	)rr�crrrrb�sz_NNTPBase._getrespcCs�d}z�t|ttf�r"t|d�}}|��}|dd�tkrBt|��g}|dk	r�dtdf}|�	d�}||krnq�|�
d�r�|dd�}|�|�qZn8d}|�	�}||kr�q�|�
d�r�|dd�}|�|�q�W5|r�|��X||fS)N�wb��.s.
Fs..r2)
�closer*�strr�openrb�	_LONGRESPrr�r�rDr�r+)rr`Z
openedFilerrZterminatorsr:�
terminatorrrr�_getlongresp�s4	



z_NNTPBase._getlongrespcCs|�|�|��Srl)r�rbr�rrr�	_shortcmd�s
z_NNTPBase._shortcmdcCs|�|�|�|�Srl�r�r�)rr:r`rrr�_longcmds
z_NNTPBase._longcmdcs.��|���|�\}}|�fdd�|D�fS)Ncsg|]}|��j�j��qSr)r,r�r���.0r:rmrr�
<listcomp>s�z,_NNTPBase._longcmdstring.<locals>.<listcomp>r�)rr:r`r�listrrmr�_longcmdstring	s

�z_NNTPBase._longcmdstringcCsdz|jWStk
rYnXz|�d�\}}Wn tk
rPtdd�}Yn
Xt|�}||_|S)NzLIST OVERVIEW.FMT)Z_cachedoverviewfmt�AttributeErrorr�rr7r?)rrrr9rrr�_getoverviewfmtsz_NNTPBase._getoverviewfmtcCsdd�|D�S)NcSsg|]}t|����qSr)r rAr�rrrr�&sz(_NNTPBase._grouplist.<locals>.<listcomp>r)rrrrr�
_grouplist$sz_NNTPBase._grouplistcCs8i}|�d�\}}|D]}|��^}}|||<q||fS)NZCAPABILITIES)r�rA)rr�rrr:r;rErrrr|(s
z_NNTPBase.capabilities)r`cCsbt|tjtjf�s$td�|jj���t||jdk�\}}d�||�}|�	||�\}}||�
|�fS)N�Athe date parameter must be a date or datetime object, not '{:40}'rJzNEWGROUPS {0} {1})r*rPr�	TypeErrorrU�	__class__rrWr{r�r�)rrr`rQrR�cmdrrrrr�	newgroups6s��z_NNTPBase.newgroupscCsRt|tjtjf�s$td�|jj���t||jdk�\}}d�|||�}|�	||�S)Nr�rJzNEWNEWS {0} {1} {2})
r*rPrr�rUr�rrWr{r�)rr!rr`rQrRr�rrr�newnewsFs��z_NNTPBase.newnewscCs4|dk	rd|}nd}|�||�\}}||�|�fS)NzLIST ACTIVE ZLIST)r�r�)r�
group_patternr`�commandrrrrrr�Vs

z_NNTPBase.listcCs�t�d�}|�d|�\}}|�d�s8|�d|�\}}i}|D]:}|�|���}|r@|�dd�\}	}
|sr|
S|
||	<q@|r�||fSdSdS)Nz^(?P<group>[^ 	]+)[ 	]+(.*)$zLIST NEWSGROUPS r�XGTITLE r2rJr()�re�compiler�rD�search�stripr!)rr�Z
return_all�line_patrr�groups�raw_line�matchr;Zdescrrr�_getdescriptionses


z_NNTPBase._getdescriptionscCs|�|d�S)NF�r�)rr!rrr�description|sz_NNTPBase.descriptioncCs|�|d�S)NTr�)rr�rrr�descriptions�sz_NNTPBase.descriptionscCs�|�d|�}|�d�s t|��|��}d}}}t|�}|dkr�|d}|dkr�|d}|dkr�|d}|dkr�|d��}|t|�t|�t|�|fS)NzGROUP rrr2rJr�rK)r�rDrrAr8r4rB)rr;r�words�countr#r"�nrrrr!�s

z_NNTPBase.groupcCs|�d|�S)NZHELP)r�)rr`rrr�help�sz_NNTPBase.helpcCs8|�d�st|��|��}t|d�}|d}|||fS)NZ22r2rJ)rDrrArB)rrr��art_numr&rrr�
_statparse�s
z_NNTPBase._statparsecCs|�|�}|�|�Srl)r�r�)rr:rrrr�_statcmd�s
z_NNTPBase._statcmdcCs"|r|�d�|��S|�d�SdS)NzSTAT {0}ZSTAT)r�rU)r�message_specrrr�stat�s	z_NNTPBase.statcCs
|�d�S)NZNEXT�r�rmrrr�next�sz_NNTPBase.nextcCs
|�d�S)NZLASTr�rmrrrr"�sz_NNTPBase.lastcCs0|�||�\}}|�|�\}}}|t|||�fSrl)r�r�r%)rr:r`rrr�r&rrr�_artcmd�sz_NNTPBase._artcmdcCs$|dk	rd�|�}nd}|�||�S)NzHEAD {0}ZHEAD�rUr��rr�r`r�rrr�head�sz_NNTPBase.headcCs$|dk	rd�|�}nd}|�||�S)NzBODY {0}ZBODYr�r�rrr�body�sz_NNTPBase.bodycCs$|dk	rd�|�}nd}|�||�S)NzARTICLE {0}ZARTICLEr�r�rrr�article�sz_NNTPBase.articlecCs
|�d�S)NZSLAVE)r�rmrrr�slavesz_NNTPBase.slavecsDt�d��|�d�||�|�\}}�fdd��|�fdd�|D�fS)Nz^([0-9]+) ?(.*)
?zXHDR {0} {1}cs��|�}|r|�dd�S|S)Nr2rJ)r�r!)r:�m)�patrr�
remove_numbers
z%_NNTPBase.xhdr.<locals>.remove_numbercsg|]}�|��qSrrr�)r�rrr�sz"_NNTPBase.xhdr.<locals>.<listcomp>)r�r�r�rU)rZhdrr�r`rrr)r�r�r�xhdrs	
z_NNTPBase.xhdrcCs.|�d�||�|�\}}|��}|t||�fS)Nz
XOVER {0}-{1})r�rUr�rI)r�start�endr`rrr9rrr�xovers
	�z_NNTPBase.xoverc	Csxd|jkrdnd}t|ttf�r>|\}}|d�||p6d�7}n|dk	rR|d|}|�||�\}}|��}|t||�fS)NZOVERZXOVERz {0}-{1}r(rz)rdr*�tupler�rUr�r�rI)	rr�r`r�r�r�rrr9rrr�over*sz_NNTPBase.overc	Csft�dtd�t�d�}|�d||�\}}g}|D](}|�|���}|r4|�|�	dd��q4||fS)NzFThe XGTITLE extension is not actively used, use descriptions() insteadrJz^([^ 	]+)[ 	]+(.*)$r�r2)
�warnings�warn�DeprecationWarningr�r�r�r�r�r+r!)	rr!r`r�rZ	raw_linesrr�r�rrr�xgtitleEs�
z_NNTPBase.xgtitlecCslt�dtd�|�d�|��}|�d�s0t|��z|��\}}Wntk
r^t|�d�Yn
X||fSdS)Nz(The XPATH extension is not actively usedrJz	XPATH {0}Z223)	r�r�r�r�rUrDrrA�
ValueError)r�idrZresp_num�pathrrr�xpathWs�
z_NNTPBase.xpathcCsb|�d�}|�d�st|��|��}t|�dkr8t|��|d}t|�dkrTt|��|t|d�fS)NZDATEZ111rJr2�)r�rDrrAr8r
rT)rr�elemrrrrrks

z_NNTPBase.datecCs�|�|�}|�d�st|��t|ttf�r2|��}|D]:}|�t�sR|�	d�t}|�d�rdd|}|j
�|�q6|j
�d�|j
��|�
�S)N�3rr�s.
)r�rDrr*r�	bytearray�
splitlines�endswithr��rstripr`r�r�rb)rr��frr:rrr�_post|s




z_NNTPBase._postcCs|�d|�S)NZPOST)r�)r�datarrr�post�sz_NNTPBase.postcCs|�d�|�|�S)Nz	IHAVE {0})r�rU)rr&r�rrr�ihave�sz_NNTPBase.ihavecCs|j��|`dSrl)r`r�rmrrrrr�s
z_NNTPBase._closecCsz|�d�}W5|��X|S)NZQUIT)rrr�)rrrrrrs�s
z_NNTPBase.quitcCs�|jrtd��|s|std��z<|rX|sXddl}|��}|�|j�}|rX|d}|d}Wntk
rnYnX|sxdS|�d|�}|�d�r�|s�t|��n |�d|�}|�d�s�t	|��d|_
|��|jr�d	|j
kr�|�
�d|_
|��dS)
NzAlready logged in.z7At least one of `user` and `usenetrc` must be specifiedrrJzauthinfo user Z381zauthinfo pass Z281r^)rir��netrcZauthenticatorsr_rtr�rDrrrdrerfrg)r�user�password�usenetrcr�ZcredentialsZauthrrrr�login�s>�


z_NNTPBase.loginc
Cs`z|�d�|_WnJtk
r$Yn8tk
rZ}z|j�d�rHd|_n�W5d}~XYnXdS)Nzmode readerZ480T)r�rcrrr
rDrf)r�errrrg�sz_NNTPBase._setreadermodecCs||jrtd��|jrtd��|�d�}|�d�rp|j��t|j||j	�|_|j�
d�|_d|_d|_|��nt
d��dS)NzTLS is already enabled.z+TLS cannot be started after authentication.�STARTTLSZ382�rwbTzTLS failed to start.)rhr�rir�rDr`r�r[rYr_�makefilerdrer)rrZrrrr�starttls�s



z_NNTPBase.starttls)T)N)N)N)N)N)N)N)N)N)NNT)N)9rrrr�r�rrrnrvryrer��debugr�r�r�rbr�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�r�r�rr�r�r�rrrsr�rg�	_have_sslr�rrrrr\)sn
�
/		

.







		
)
r\c@s*eZdZeddddefdd�Zdd�ZdS)rNFc	Cs�||_||_t�d|||�t�||f|�|_d}z8|j�d�}t�	|||||�|sZ|rh|�
|||�Wn$|r~|��|j���YnXdS)N�nntplib.connectr�)r_�portr�r��socket�create_connectionrYr�r\rr�r�)	rr_r�r�r�rjr�rkr`rrrr�s$
�
z
NNTP.__init__cCs zt�|�W5|j��XdSrl�rYr�r\rrrmrrrrr$szNNTP._close)rrr�	NNTP_PORTrrrrrrrrr�s�
%c@s,eZdZedddddefdd�Zdd�ZdS)�NNTP_SSLNFc	
Cs�t�d|||�t�||f|�|_d}	zJt|j||�|_|j�d�}	tj||	|||d�|s`|rn|�	|||�Wn$|	r�|	�
�|j�
��YnXdS)Nr�r�)rjrk)r�r�r�r�rYr[r�r\rr�r�)
rr_r�r�r�Zssl_contextrjr�rkr`rrrr.s"
�
zNNTP_SSL.__init__cCs zt�|�W5|j��XdSrlr�rmrrrrrEszNNTP_SSL._close)rrr�
NNTP_SSL_PORTrrrrrrrrr�,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�)r_r�r�ZGroupZhaszarticles, range�tocCs$t|�|kr |d|d�d}|S)NrKz...)r8)�sZlimrrr�cutpsr	r2�<z{:7} {:20} {:42} ({})��*)N)N)F)Jr�r��collectionsrPr�r�rX�ImportErrorr�Zemail.headerrr)r�__all__r�rrrrrr	r
r�rr�r7r5r��
namedtupler r%r?rIrTrWr[r\rr�r+r�argparse�ArgumentParser�parser�add_argumentrB�
parse_argsrr�Zserverrrer�r�r!rr�r#r"r;rwr	r�Znb_articlesr�Z	overviewsZartnumr�rAZauthorrrrUrsrrrr�<module>Bs�
�
	���
��


Y.


�
�
���


�