
    5i                     x    d Z ddlmZmZmZmZ ddlZddlmZm	Z	m
Z
mZ ddlmZmZmZ ddlmZ dd	lmZ d
 Zd Zy)z
This submodule handles copy commands for the dx
command-line client.

'dx cp' works only between DIFFERENT projects. It will exit fatally otherwise.
    )print_functionunicode_literalsdivisionabsolute_importN   )resolve_existing_pathresolve_path	is_hashidget_last_pos_of_char)err_exit
DXCLIErrorResourceNotFound   )try_call)fillc           	         t        | j                        dk7  rt        d      t        d|      }|dk(  rd}n|d| }||dz   d j	                  dd      }	 |j                  |d       t        t        | j                  d   d	| j                  
      \  }}	}
||k(  rSt        | j                  d         r$t        t        d| j                  d   z               t        t        d      dz         |
	 t        j                   j#                  ||	d	d      }t        j                   j%                  |d|i       t        j                   j'                  ||d   |d   D cg c]  }|d   	 c}||d      d   }t        |      dkD  r*t)        t        d      dz   dj+                  |      z          yy	 t        j                   j'                  ||
D cg c]  }|d   	 c}||d      d   }t        |      dkD  r)t)        t        d      dz   dj+                  |      z          |
D ],  }|d   |vst        j,                  d|d   z   dz   ||d       . y# t        j                  $ r!}t        |t              rt        d       d}~w t                Y )xY wc c}w #  t                Y yxY wc c}w #  t                Y yxY w)zx Copy the source to a destination that does not currently
    exist. This involves creating the target file/folder.
    r   z%The destination folder does not exist/r   Nz\/foldersfolderonlyT
allow_multall_mult-Error: You must specify a source project for zA source path and the destination path resolved to the same project or container.  Please specify different source and destination containers, e.g.@
  dx cp source-project:source-id-or-path dest-project:dest-path)r   includeHiddenr   objectsid)r   r   projectdestinationexistszWThe following objects already existed in the destination container and were not copied:
 )r   r    r!   z/rename)r    name)lensourcesr   r   replacelist_folderdxpy
DXAPIError
isinstancer   r   r   r   allr
   r   apiproject_list_folderproject_new_folderproject_cloneprintjoinDXHTTPRequest)args	dest_pathdx_dest	dest_projlast_slash_posdest_folder	dest_nameesrc_projsrc_pathsrc_resultscontentsresultr"   s                 m/home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/dxpy/cli/cp.pycp_to_noexistent_destinationrB   !   s   
 4<<A@AA)#y9N0.1,-.66tSAI;Y? '//D/3||A:>'S#Hh 9T\\!_% T"QTXT`T`abTc"cdeeT #C D aa b b
 	xx33H?GZ^4_aHHH''	Hi3HIXX++H8@8KT\]fTg8h&8h8A<E-GH IQ	RF
 6{Qd < =?DEGLzzRXGYZ [ 	XX++HT_8`&8`8A<G-IJ KSTF 6{Qd < =?DEGLzzRXGYZ [% <$<v-&&sVD\'9I'E3<09(;<<
 o ?? a)*DEE
4 9i	J 9a	Js]   I 2A*J J(AJ 0J0 J+
AJ0 ,$J0 J$J  JJ J(+J0 0J>c           	         t        t        | j                  d      \  }}}|t        d      t	        j
                  |      }	 |j                  |d       t        | j                        dk(  rt        d      g }g }| j                  D ]  }t        t        |d| j                  	      \  }}	}
||k(  r9t        |      rt        t        d
|z               t        t        d      dz         |t        t        d            |
|j                  |	       ||
D cg c]  }|d   	 c}z  } 	 t	        j                  dz   dz   ||||| j                   d      d   }t        |      dkD  r*t#        t        d      dz   dj%                  |      z          y y #  t        | |||       Y y xY wc c}w #  t'                Y y xY w)Nr   )expectedzCannot copy to a hash IDr   r   r   z.No sources provided to copy to another projectTr   r   zError: A source path and the destination path resolved to the same project or container. Please specify different source and destination containers, e.g.r   zmError: A source project must be specified or a current project set in order to clone objects between projectsr   r   z/clone)r   r   r    r!   targetFileRelocationr"   zWThe following objects already existed in the destination container and were left alone:r#   )r   r	   r!   r   r)   get_handlerr(   rB   r%   r&   r   r,   r
   r   appendr3   target_file_relocationr1   r2   r   )r4   r7   r5   _noner6   src_objectssrc_folderssourcer<   src_folderpathr>   r@   r"   s                rA   cprN   m   s   "*<9I9IT\"]Iy%344y)G99= 4<<AIJJKK,, D089N9?DHSWS[S[1]-.+ y   !&UX^&^!_``  'X "Y "e"e f f
 T #[ \ ] ] ~.{CVF4LCCK-D.##C(NX$=0;0;094==A=X=X	%Z[
 \de v;?$ . /1679>F9KL M O$T9gyI: D
s   F F,/A&F1 F)1F?)__doc__
__future__r   r   r   r   r)   utils.resolverr   r	   r
   r   
exceptionsr   r   r    r   dxpy.utils.printingr   rB   rN        rA   <module>rW      s4   " S R  c c A A  &IX3rV   