aboutsummaryrefslogblamecommitdiffstats
path: root/util/zotsh/easywebdav/client.pyc
blob: cf074d522992608541b3e5c1a02975c518853e8f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
   
                                                                                                              


                                                                                                                                                                                  

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          


                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                  



                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                     






                                                                                                                                                                                                                                                            




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

                                                                                                                                            

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
 
�
Y�"Xc@sLddlZddlZddlmZddljjZddlm	Z	ej
�\ZZZ
edkr�ddlmZddlmZn ddlmZddlmZdZd	efd
��YZdefd��YZd
�Ze	ddddddg�Zdd�Zd�Zdefd��YZdefd��YZdS(i����N(tNumber(t
namedtuplet2(t	responses(turlparseiitWebdavExceptioncBseZRS((t__name__t
__module__(((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyRstConnectionFailedcBseZRS((RR(((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyRscCstj|d�S(NtUNKNOWN(t
HTTP_CODEStget(tcode((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pytcodestrstFiletnametsizetmtimetctimetcontenttypecCs*|jd|�}|dkr#|S|jS(Ns	.//{DAV:}(tfindtNonettext(telemRtdefaulttchild((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pytprop sc	CsUtt|d�tt|dd��t|dd�t|dd�t|dd��S(Nthreftgetcontentlengthitgetlastmodifiedttcreationdatetgetcontenttype(RRtint(R((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyt	elem2file%stOperationFailedc
Bs>eZedddddddddd	d
d�Zd�ZRS(
tHEADs
get headertGETtdownloadtPUTtuploadtDELETEtdeletetMKCOLscreate directorytPROPFINDslist directoryc
Cs�||_||_||_||_|j|}djt��|_t|t	�r^|fn|}dj
d�|D��}t|�}djt��}	tt
|�j|	�dS(Ns#Failed to {operation_name} "{path}"s, css'|]}dj|t|��VqdS(s{0} {1}N(tformatR
(t.0R((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pys	<genexpr>Ass�{self.reason}.
  Operation     :  {method} {path}
  Expected code :  {expected_codes_str}
  Actual code   :  {actual_code} {actual_code_str}(tmethodtpatht
expected_codetactual_codet_OPERATIONSR-tlocalstreasont
isinstanceRtjoinR
tsuperR#t__init__(
tselfR/R0R1R2toperation_nametexpected_codestexpected_codes_strtactual_code_strtmsg((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyR99s				
(RRtdictR3R9(((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyR#/s	tClientc
Bs�eZdddddedddd�	Zd�Zd�Zd�Zed�Z	d�Z
ed�Zd	�Zd
�Z
d�Zd�Zd
�Zdd�Zd�ZRS(ithttpcCs�|s!|dkrdnd}ndj|||�|_|rZdj|j|�|_nd|_|
dkr�tj�|_n	|
|_||j_t|j_|	r�|	|j_	n|r�||j_
n!|r�|r�||f|j_
ndS(Nthttpsi�iPs
{0}://{1}:{2}s{0}/{1}t/(R-tbaseurltcwdRtrequeststsessiontverifytTruetstreamtcerttauth(R:thosttportRMtusernametpasswordtprotocolt
verify_sslR0RLRH((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyR9Ks"		cKs�|j|�jd�}|jj||dt|�}t|t�rT|j|ksst|t�r�|j|kr�t||||j��n|S(Nt.tallow_redirects(	t_get_urltstripRHtrequesttFalseR6Rtstatus_codeR#(R:R/R0R1tkwargsturltresponse((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyt_sendbscCsHt|�j�}|jd�r,|j|Sdj|j|j|f�S(NRDR(tstrRWt
startswithRER7RF(R:R0((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyRVpscCs�|j�}|sdSdjd�|jd�D��d}|dkrT||_ns|jd�rsd||_nT|dkr�dS|dkr�dj|jjd�d �d|_n|j|7_dS(NRDcss|]}|r|VqdS(N((R.tpart((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pys	<genexpr>zss./s../i����(RWR7tsplitRFR`(R:R0t
stripped_path((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pytcdvs&)cCs)|sdnd}|jd||�dS(Ni�i-i�R+(i�i-i�(R^(R:R0tsafeR<((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pytmkdir�scCs�g|jd�D]}|r|^q}|s2dS|jd�rVd|d|d<n|j}zlxe|D]]}zFy|j|dt�Wn(tk
r�}|jdkr��q�nXWd|j|�XqiWWd|j|�XdS(NRDiRei�(RbR`RFRfRJt	ExceptionR2Rd(R:R0tdtdirstold_cwdtdirte((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pytmkdirs�s (	
cCsBt|�jd�d}|s%dnd}|jd||�dS(NRDi�i�R)(i�i�(R_trstripR^(R:R0ReR<((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pytrmdir�scCs|jd|d�dS(NR)i�(R^(R:R0((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyR*�scCsNt|t�r:t|d��}|j||�WdQXn|j||�dS(Ntrb(R6t
basestringtopent_upload(R:tlocal_path_or_fileobjtremote_pathtf((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyR(�scCs|jd|dd|�dS(NR'i�i�i�tdata(i�i�i�(R^(R:tfileobjRu((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyRs�scCsi|jd|ddt�}t|t�rUt|d��}|j||�WdQXn|j||�dS(NR%i�RKtwb(R^RJR6RqRrt	_download(R:RuRtR]Rv((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyR&�s
cCs+x$|jt�D]}|j|�qWdS(N(titer_contenttDOWNLOAD_CHUNK_SIZE_BYTEStwrite(R:RxR]tchunk((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyRz�sRTcCs�idd6}|jd|d	d|�}|jdkrZt|jd�}|j|j�Stj|j�}g|j	d�D]}t
|�^q|S(
Nt1tDepthR,i�i-theaderstlocations{DAV:}response(i�i-(R^RZRR�tlsR0txmlt
fromstringtcontenttfindallR"(R:RuR�R]R\ttreeR((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyR��s
cCs,|jd|d�}|jdkr(tStS(NR$i�i-i�(i�i-i�(R^RZRJRY(R:RuR]((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pytexists�sN(RRRRJR9R^RVRdRYRfRmRoR*R(RsR&RzR�R�(((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyRAJs									ii( RGtplatformtnumbersRtxml.etree.cElementTreetetreetcElementTreeR�tcollectionsRtpython_version_tuplet
py_majversiont
py_minversiont
py_revversionthttplibRR
Rthttp.clientturllib.parseR|RgRRR
RRRR"R#tobjectRA(((s2/home/macgirvin/hz/util/zotsh/easywebdav/client.pyt<module>s&