AlkantarClanX12

Your IP : 3.133.128.227


Current Path : /proc/self/root/usr/lib64/python3.6/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib64/python3.6/__pycache__/nntplib.cpython-36.opt-2.pyc

3


 \F��@s�ddlZddlZddlZddlZddlZyddlZWnek
rLdZYnXdZddlm	Z
ddlmZdddd	d
ddd
gZdZ
Gdd�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+Zejd,d-d.d/d0g�Zejd1d2d3d4g�Zd5d
�Z	d6d7�Zdkd8d9�Zdld:d;�Z dmd<d=�Z!e�r�d>d?�Z"Gd@dA�dA�Z#GdBd�de#�Z$e�r�GdCdD�dDe#�Z%ej&dD�e'dEk�r|ddl(Z(e(j)dFdG�Z*e*j+dHdIdJdKdL�e*j+dMdNdOdPdL�e*j+dQdRdne,dTeefdU�e*j+dVdWdXe,dYdU�e*j+dZd[d\dd]d^�e*j-�Z.e.j/Z/e.j�s�e/dok�rpeZ/e$e.j0e/d_�Z1ne/dpk�r�eZ/e%e.j0e/d_�Z1e1j2�Z3d`e3k�r�e1j4�e1j5e.j5�\Z6Z7Z8Z9Z:e;dae:dbe7dce8dde9�dedf�Z<e=e,e9�e.j>dS�Z8e1j?e8e9�\Z6Z@xbe@D]Z\ZAZBe	eBd$�jCdgdS�dZDe	eBd#�ZEe,eBd)�ZFe;dhjGeAe<eDdi�e<eEdj�eF���qWe1jH�dS)q�NFT)�
decode_header)�_GLOBAL_DEFAULT_TIMEOUT�NNTP�	NNTPError�NNTPReplyError�NNTPTemporaryError�NNTPPermanentError�NNTPProtocolError�
NNTPDataErrorric@seZdZdd�ZdS)rcGs>tj|f|��y|d|_Wntk
r8d|_YnXdS)NrzNo response given)�	Exception�__init__�response�
IndexError)�self�args�r�/usr/lib64/python3.6/nntplib.pyrbs
zNNTPError.__init__N)�__name__�
__module__�__qualname__rrrrrr`sc@seZdZdS)rN)rrrrrrrrisc@seZdZdS)rN)rrrrrrrrmsc@seZdZdS)rN)rrrrrrrrqsc@seZdZdS)r	N)rrrrrrrr	usc@seZdZdS)r
N)rrrrrrrr
ys�wi3Z100Z101�211�215Z220Z221Z222Z224Z225Z230Z231Z282�subject�from�datez
message-idZ
referencesz:bytesz:lines)�bytes�liness
�	GroupInfo�group�last�first�flag�ArticleInfoZnumber�
message_idrcCsNg}x>t|�D]2\}}t|t�r6|j|j|p.d��q|j|�qWdj|�S)N�ascii�)�_email_decode_header�
isinstancer�append�decode�join)Z
header_str�parts�v�encrrrr�s
cCs�g}xh|D]`}|ddkr<|dd�jd�\}}}d|}n|jd�\}}}|j�}tj||�}|j|�q
Wt}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�_�suffixZdefaultsrrr�_parse_overview_fmt�s

r<cCs�tt�}g}x�|D]�}i}|jd�^}}t|�}x�t|�D]�\}	}
|	t|�krPq:||	}|jd�}|	|kr�|r�|d}
|
r�|
dt|
��j�|
kr�td��|
r�|
t|
�d�nd}
|
|||	<q:W|j||f�qW|S)N�	r/z: z?OVER/XOVER response doesn't include names of additional headers)	r6r5�split�int�	enumerate�
startswithr2r
r))rr7Zdata_process_funcZ
n_defaultsZoverviewr8ZfieldsZarticle_number�tokens�i�tokenZ
field_nameZis_metadata�hrrr�_parse_overview�s&

rFcCs�|dkr |dd�}|dd	�}t|dd��}t|dd��}t|dd��}t|dd
��}t|dd��}t|d
d��}|dkr�|d7}n|dkr�|d7}tj||||||�S)N����Fi��dili����i�������rL���rM)r?�datetime)�date_str�time_strZhoursZminutesZseconds�yearZmonthZdayrrr�_parse_datetime�s
rRcCsPt|tj�sd}n
dj|�}|j}|r<|d}dj||�}ndj||�}||fS)NZ000000z({0.hour:02d}{0.minute:02d}{0.second:02d}rKz{0:02d}{1.month:02d}{1.day:02d}z{0:04d}{1.month:02d}{1.day:02d})r(rN�formatrQ)ZdtZlegacyrP�yrOrrr�_unparse_datetime�s

rUcCs|dkrtj�}|j||d�S)N)Zserver_hostname)�sslZ_create_stdlib_contextZwrap_socket)�sock�contextZhostnamerrr�_encrypt_onsrYc@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|_|j�|_d|_|j�d|_|rZd|jkrZ|j�|jsZd|_|j�d|_	d|_
dS)NrF�READER)�host�file�	debugging�_getresp�welcome�_caps�getcapabilities�readermode_afterauth�_setreadermode�tls_on�
authenticated)rr^r]�
readermode�timeoutrrrr8s
	z_NNTPBase.__init__cCs|S)Nr)rrrr�	__enter__gsz_NNTPBase.__enter__csR�fdd�}|�rNz*y�j�Wnttfk
r8YnXWd|�rL�j�XdS)Ncs
t�d�S)Nr^)�hasattrr)rrr�<lambda>ksz$_NNTPBase.__exit__.<locals>.<lambda>)�quit�OSError�EOFError�_close)rrZis_connectedr)rr�__exit__js
z_NNTPBase.__exit__cCs|jrtdt|j��|jS)Nz	*welcome*)r_�print�reprra)rrrr�
getwelcomeusz_NNTPBase.getwelcomec
Cs�|jdkr�d|_d|_y|j�\}}Wnttfk
rDi|_Yn<X||_d|krhttt|d��|_d|kr�dj	|d�|_|jS)Nr0�VERSIONZIMPLEMENTATION� )
rb�nntp_versionZnntp_implementation�capabilitiesrr�max�mapr?r+)r�resp�capsrrrrc~s
z_NNTPBase.getcapabilitiescCs
||_dS)N)r_)r�levelrrr�set_debuglevel�sz_NNTPBase.set_debuglevelcCs:|t}|jdkr tdt|��|jj|�|jj�dS)Nr0z*put*)�_CRLFr_rrrsr^�write�flush)rr8rrr�_putline�s

z_NNTPBase._putlinecCs2|jrtdt|��|j|j|j�}|j|�dS)Nz*cmd*)r_rrrs�encode�encoding�errorsr�)rr8rrr�_putcmd�sz_NNTPBase._putcmdTcCs�|jjtd�}t|�tkr$td��|jdkr<tdt|��|sDt�|r�|dd�t	krf|dd�}n|dd�t	kr�|dd�}|S)	Nr0z
line too longz*get*rHrMrM���r�)
r^�readline�_MAXLINEr6r
r_rrrsror)rZ
strip_crlfr8rrr�_getline�s
z_NNTPBase._getlinecCsl|j�}|jrtdt|��|j|j|j�}|dd�}|dkrHt|��|dkrXt|��|dkrht	|��|S)Nz*resp*r0�4�5Z123)
r�r_rrrsr*r�r�rrr	)rr{�crrrr`�sz_NNTPBase._getrespc
Cs�d}z�t|ttf�r"t|d�}}|j�}|dd�tkrBt|��g}|dk	r�dtdf}xv|jd�}||krpP|j	d�r�|dd�}|j
|�q\Wn<d}x6|j�}||kr�P|j	d�r�|dd�}|j|�q�WWd|r�|j�X||fS)N�wb��.s.
Fs..r0)
r(�strr�openr`�	_LONGRESPrrr�rAr�r)�close)rr^Z
openedFiler{rZterminatorsr8�
terminatorrrr�_getlongresp�s8	



z_NNTPBase._getlongrespcCs|j|�|j�S)N)r�r`)rr8rrr�	_shortcmd�s
z_NNTPBase._shortcmdcCs|j|�|j|�S)N)r�r�)rr8r^rrr�_longcmds
z_NNTPBase._longcmdcs.�j|��j|�\}}|�fdd�|D�fS)Ncsg|]}|j�j�j��qSr)r*r�r�)�.0r8)rrr�
<listcomp>sz,_NNTPBase._longcmdstring.<locals>.<listcomp>)r�r�)rr8r^r{�listr)rr�_longcmdstrings
z_NNTPBase._longcmdstringcCsby|jStk
rYnXy|jd�\}}Wn tk
rNtdd�}Yn
Xt|�}||_|S)NzLIST OVERVIEW.FMT)Z_cachedoverviewfmt�AttributeErrorr�rr5r<)rr{rr7rrr�_getoverviewfmtsz_NNTPBase._getoverviewfmtcCsdd�|D�S)NcSsg|]}t|j���qSr)rr>)r�r8rrrr�$sz(_NNTPBase._grouplist.<locals>.<listcomp>r)rrrrr�
_grouplist"sz_NNTPBase._grouplistcCs<i}|jd�\}}x |D]}|j�^}}|||<qW||fS)NZCAPABILITIES)r�r>)rr|r{rr8r9rBrrrrx&s
z_NNTPBase.capabilities)r^cCsbt|tjtjf�s$tdj|jj���t||jdk�\}}dj||�}|j	||�\}}||j
|�fS)NzAthe date parameter must be a date or datetime object, not '{:40}'rHzNEWGROUPS {0} {1})r(rNr�	TypeErrorrS�	__class__rrUrwr�r�)rrr^rOrP�cmdr{rrrr�	newgroups4sz_NNTPBase.newgroupscCsRt|tjtjf�s$tdj|jj���t||jdk�\}}dj|||�}|j	||�S)NzAthe date parameter must be a date or datetime object, not '{:40}'rHzNEWNEWS {0} {1} {2})
r(rNrr�rSr�rrUrwr�)rrrr^rOrPr�rrr�newnewsDsz_NNTPBase.newnewscCs4|dk	rd|}nd}|j||�\}}||j|�fS)NzLIST ACTIVE ZLIST)r�r�)r�
group_patternr^�commandr{rrrrr�Ts

z_NNTPBase.listcCs�tjd�}|jd|�\}}|jd�s8|jd|�\}}i}x>|D]6}|j|j��}|rB|jdd�\}	}
|sp|
S|
||	<qBW|r�||fSdSdS)Nz^(?P<group>[^ 	]+)[ 	]+(.*)$zLIST NEWSGROUPS rzXGTITLE r0rHr&)�re�compiler�rA�search�stripr)rr�Z
return_all�line_patr{r�groups�raw_line�matchr9Zdescrrr�_getdescriptionscs


z_NNTPBase._getdescriptionscCs|j|d�S)NF)r�)rrrrr�descriptionzsz_NNTPBase.descriptioncCs|j|d�S)NT)r�)rr�rrr�descriptions�sz_NNTPBase.descriptionscCs�|jd|�}|jd�s t|��|j�}d}}}t|�}|dkr�|d}|dkr�|d}|dkr�|d}|dkr�|dj�}|t|�t|�t|�|fS)NzGROUP rrr0rHr�rI)r�rArr>r6r2r?)rr9r{�words�countr!r �nrrrr�s

z_NNTPBase.groupcCs|jd|�S)NZHELP)r�)rr^rrr�help�sz_NNTPBase.helpcCs8|jd�st|��|j�}t|d�}|d}|||fS)NZ22r0rH)rArr>r?)rr{r��art_numr$rrr�
_statparse�s
z_NNTPBase._statparsecCs|j|�}|j|�S)N)r�r�)rr8r{rrr�_statcmd�s
z_NNTPBase._statcmdcCs"|r|jdj|��S|jd�SdS)NzSTAT {0}ZSTAT)r�rS)r�message_specrrr�stat�s	z_NNTPBase.statcCs
|jd�S)NZNEXT)r�)rrrr�next�sz_NNTPBase.nextcCs
|jd�S)NZLAST)r�)rrrrr �sz_NNTPBase.lastcCs0|j||�\}}|j|�\}}}|t|||�fS)N)r�r�r#)rr8r^r{rr�r$rrr�_artcmd�sz_NNTPBase._artcmdcCs$|dk	rdj|�}nd}|j||�S)NzHEAD {0}ZHEAD)rSr�)rr�r^r�rrr�head�sz_NNTPBase.headcCs$|dk	rdj|�}nd}|j||�S)NzBODY {0}ZBODY)rSr�)rr�r^r�rrr�body�sz_NNTPBase.bodycCs$|dk	rdj|�}nd}|j||�S)NzARTICLE {0}ZARTICLE)rSr�)rr�r^r�rrr�article�sz_NNTPBase.articlecCs
|jd�S)NZSLAVE)r�)rrrr�slavesz_NNTPBase.slavecsDtjd��|jdj||�|�\}}�fdd��|�fdd�|D�fS)Nz^([0-9]+) ?(.*)
?zXHDR {0} {1}cs�j|�}|r|jdd�S|S)Nr0rH)r�r)r8�m)�patrr�
remove_numbers
z%_NNTPBase.xhdr.<locals>.remove_numbercsg|]}�|��qSrr)r�r8)r�rrr�sz"_NNTPBase.xhdr.<locals>.<listcomp>)r�r�r�rS)rZhdrr�r^r{rr)r�r�r�xhdr
s	
z_NNTPBase.xhdrcCs.|jdj||�|�\}}|j�}|t||�fS)Nz
XOVER {0}-{1})r�rSr�rF)r�start�endr^r{rr7rrr�xovers	
z_NNTPBase.xoverc	Csxd|jkrdnd}t|ttf�r>|\}}|dj||p6d�7}n|dk	rR|d|}|j||�\}}|j�}|t||�fS)NZOVERZXOVERz {0}-{1}r&rv)rbr(�tupler�rSr�r�rF)	rr�r^r�r�r�r{rr7rrr�over(sz_NNTPBase.overc	Csjtjdtd�tjd�}|jd||�\}}g}x0|D](}|j|j��}|r6|j|j	dd��q6W||fS)NzFThe XGTITLE extension is not actively used, use descriptions() insteadrHz^([^ 	]+)[ 	]+(.*)$zXGTITLE r0)
�warnings�warn�DeprecationWarningr�r�r�r�r�r)r)	rrr^r�r{Z	raw_linesrr�r�rrr�xgtitleCs

z_NNTPBase.xgtitlecCsjtjdtd�|jdj|��}|jd�s0t|��y|j�\}}Wntk
r\t|��Yn
X||fSdS)Nz(The XPATH extension is not actively usedrHz	XPATH {0}Z223)	r�r�r�r�rSrArr>�
ValueError)r�idr{Zresp_num�pathrrr�xpathUs
z_NNTPBase.xpathcCsb|jd�}|jd�st|��|j�}t|�dkr8t|��|d}t|�dkrTt|��|t|d�fS)NZDATEZ111rHr0�)r�rArr>r6r
rR)rr{�elemrrrrris

z_NNTPBase.datecCs�|j|�}|jd�st|��t|ttf�r2|j�}xB|D]:}|jt�sT|j	d�t}|jd�rfd|}|j
j|�q8W|j
jd�|j
j�|j
�S)N�3s
r�s.
)r�rArr(r�	bytearray�
splitlines�endswithr�rstripr^r�r�r`)rr��fr{r8rrr�_postzs





z_NNTPBase._postcCs|jd|�S)NZPOST)r�)r�datarrr�post�sz_NNTPBase.postcCs|jdj|�|�S)Nz	IHAVE {0})r�rS)rr$r�rrr�ihave�sz_NNTPBase.ihavecCs|jj�|`dS)N)r^r�)rrrrrp�s
z_NNTPBase._closec
Csz|jd�}Wd|j�X|S)NZQUIT)r�rp)rr{rrrrm�s
z_NNTPBase.quitcCs�|jrtd��|r"|r"td��y>|r^|r^ddl}|j�}|j|j�}|r^|d}|d}Wntk
rtYnX|s~dS|jd|�}|jd�r�|s�t|��n |jd|�}|jd�s�t	|��d|_
|j�|jr�d	|j
kr�|j
�d|_
|j�dS)
NzAlready logged in.z7At least one of `user` and `usenetrc` must be specifiedrrHzauthinfo user Z381zauthinfo pass Z281r\)rgr��netrcZauthenticatorsr]rnr�rArrrbrcrdre)r�user�password�usenetrcr�ZcredentialsZauthr{rrr�login�s<



z_NNTPBase.logincCs`y|jd�|_WnJtk
r$Yn8tk
rZ}z|jjd�rHd|_n�WYdd}~XnXdS)Nzmode readerZ480T)r�rarrr
rArd)r�errrre�sz_NNTPBase._setreadermodecCs||jrtd��|jrtd��|jd�}|jd�rp|jj�t|j||j	�|_|jj
d�|_d|_d|_|j�nt
d��dS)NzTLS is already enabled.z+TLS cannot be started after authentication.�STARTTLSZ382�rwbTzTLS failed to start.)rfr�rgr�rAr^r�rYrWr]�makefilerbrcr)rrXr{rrr�starttls�s



z_NNTPBase.starttls)T)N)N)N)N)N)N)N)N)N)NNT)N)9rrrr�r�rrrjrqrtrcr~�debugr�r�r�r`r�r�r�r�r�r�rxr�r�r�r�r�r�rr�r�r�r�r�r r�r�r�r�r�r�r�r�r�r�rr�r�r�rprmr�re�	_have_sslr�rrrrrZ(sj
.	

.







		
)
rZc@s*eZdZeddddefdd�Zdd�ZdS)rNFc	Cs�||_||_tj||f|�|_d}y8|jjd�}tj|||||�|sJ|rX|j|||�Wn$|rn|j	�|jj	��YnXdS)Nr�)
r]�port�socket�create_connectionrWr�rZrr�r�)	rr]r�r�r�rhr�rir^rrrr�s

z
NNTP.__init__c
Cs ztj|�Wd|jj�XdS)N)rZrprWr�)rrrrrp!szNNTP._close)rrr�	NNTP_PORTrrrprrrrr�s"c@s,eZdZedddddefdd�Zdd�ZdS)�NNTP_SSLNFc	

Cs�tj||f|�|_d}	yJt|j||�|_|jjd�}	tj||	|||d�|sP|r^|j|||�Wn$|	rt|	j�|jj��YnXdS)Nr�)rhri)	r�r�rWrYr�rZrr�r�)
rr]r�r�r�Zssl_contextrhr�rir^rrrr+s


zNNTP_SSL.__init__c
Cs ztj|�Wd|jj�XdS)N)rZrprWr�)rrrrrpAszNNTP_SSL._close)rrr�
NNTP_SSL_PORTrrrprrrrr�)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--serverznews.gmane.orgz+NNTP server hostname (default: %(default)s)z-pz--portr0z#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)�actionr�r�)r]r�r�ZGroupZhaszarticles, rangeZtocCs$t|�|kr |d|d�d}|S)NrIz...)r6)�sZlimrrr�cutlsr��<z{:7} {:20} {:42} ({})��*)N)N)Fr�r�r�)Ir�r��collectionsrNr�rV�ImportErrorr�Zemail.headerrr'r�__all__r�rrrrrr	r
r�r�r�r5r3r�
namedtuplerr#r<rFrRrUrYrZrr�r)r�argparse�ArgumentParser�parser�add_argumentr?�
parse_argsrr�Zserverr�rcr|r�rr{r�r!r r9rrr�r�Znb_articlesr�Z	overviewsZartnumr�r>ZauthorrrrSrmrrrr�<module>Bs�
	


X-