Your IP : 3.142.197.102


Current Path : /lib64/python2.7/
Upload File :
Current File : //lib64/python2.7/copy.pyc

�
�mec@s�dZddlZddlZddlmZdefd��YZeZyddlm	Z	Wne
k
rwdZ	nXdddgZd	�Z
iZZd
�Zx]ed�eeeeeeeeeejejee�ejejfD]Zeee<q�Wx9dD]1Z e!ee d�Zedk	r
eee<q
q
Wd�Z"x!e#e$e%fD]Ze"ee<qXWd�Z&e	dk	r�e&ee	<nd�Z'e'eej(<[dgd�Z)iZ*Zd�Z+e+eed�<e+eee�<e+ee<e+ee<e+ee<e+ee<ye+ee,<Wne-k
r2nXe+ee<ye+ee.<Wne-k
r^nXye+eej/<Wne0k
r�nXe+ee<e+ee<e+eej<e+eej<e+eej<e+eej<d�Z1e1ee#<d�Z2e2ee<d�Z3e3ee$<e	dk	re3ee	<nd�Z4e4e*ej5<d�Z6d�Z7e7eej(<dd�Z8[[ddd��YZ9d�Z:e;dkr�e:�ndS( s�Generic (shallow and deep) copying operations.

Interface summary:

        import copy

        x = copy.copy(y)        # make a shallow copy of y
        x = copy.deepcopy(y)    # make a deep copy of y

For module specific errors, copy.Error is raised.

The difference between shallow and deep copying is only relevant for
compound objects (objects that contain other objects, like lists or
class instances).

- A shallow copy constructs a new compound object and then (to the
  extent possible) inserts *the same objects* into it that the
  original contains.

- A deep copy constructs a new compound object and then, recursively,
  inserts *copies* into it of the objects found in the original.

Two problems often exist with deep copy operations that don't exist
with shallow copy operations:

 a) recursive objects (compound objects that, directly or indirectly,
    contain a reference to themselves) may cause a recursive loop

 b) because deep copy copies *everything* it may copy too much, e.g.
    administrative data structures that should be shared even between
    copies

Python's deep copy operation avoids these problems by:

 a) keeping a table of objects already copied during the current
    copying pass

 b) letting user-defined classes override the copying operation or the
    set of components copied

This version does not copy types like module, class, function, method,
nor stack trace, stack frame, nor file, socket, window, nor array, nor
any similar types.

Classes can use the same interfaces to control copying that they use
to control pickling: they can define methods called __getinitargs__(),
__getstate__() and __setstate__().  See the documentation for module
"pickle" for information on these methods.
i����N(tdispatch_tabletErrorcBseZRS((t__name__t
__module__(((s/usr/lib64/python2.7/copy.pyR7s(tPyStringMaptcopytdeepcopycCs�t|�}tj|�}|r+||�St|dd�}|rM||�Stj|�}|rq||�}n[t|dd�}|r�|d�}n4t|dd�}|r�|�}ntd|��t||d�S(slShallow copy operation on arbitrary Python objects.

    See the module's __doc__ string for more info.
    t__copy__t
__reduce_ex__it
__reduce__s%un(shallow)copyable object of type %siN(ttypet_copy_dispatchtgettgetattrtNoneRRt_reconstruct(txtclstcopiertreductortrv((s/usr/lib64/python2.7/copy.pyRBs$

cCs|S(N((R((s/usr/lib64/python2.7/copy.pyt_copy_immutableestComplexTypetUnicodeTypetCodeTypecCst|�|�S(N(R
(R((s/usr/lib64/python2.7/copy.pyt_copy_with_constructorqscCs
|j�S(N(R(R((s/usr/lib64/python2.7/copy.pyt_copy_with_copy_methodvscCs�t|d�r|j�St|d�rF|j�}|j|�}nt�}|j|_t|d�ry|j�}n	|j}t|d�r�|j|�n|jj|�|S(NRt__getinitargs__t__getstate__t__setstate__(	thasattrRRt	__class__t_EmptyClassRt__dict__Rtupdate(Rtargstytstate((s/usr/lib64/python2.7/copy.pyt
_copy_inst{s
		c
Cs�|dkri}nt|�}|j||�}||k	rC|St|�}tj|�}|rv|||�}nyt|t�}Wntk
r�d}nX|r�t||�}n�t|dd�}|r�||�}n�t	j|�}|r||�}	n[t|dd�}|r-|d�}	n4t|dd�}|rQ|�}	nt
d|��t||	d|�}|||<t||�|S(	siDeep copy operation on arbitrary Python objects.

    See the module's __doc__ string for more info.
    it__deepcopy__RiR	s"un(deep)copyable object of type %siN(
RtidRR
t_deepcopy_dispatcht
issubclasst	TypeErrort_deepcopy_atomicR
RRRt_keep_alive(
Rtmemot_niltdR$RRtisscRR((s/usr/lib64/python2.7/copy.pyR�sD	




cCs|S(N((RR.((s/usr/lib64/python2.7/copy.pyR,�scCsAg}||t|�<x$|D]}|jt||��qW|S(N(R(tappendR(RR.R$ta((s/usr/lib64/python2.7/copy.pyt_deepcopy_list�s

cCs�g}x$|D]}|jt||��q
Wt|�}y||SWntk
rXnXxDtt|��D]*}||||k	rlt|�}PqlqlW|}|||<|S(N(R2RR(tKeyErrortrangetlenttuple(RR.R$R3R0ti((s/usr/lib64/python2.7/copy.pyt_deepcopy_tuple�s


cCsSi}||t|�<x6|j�D](\}}t||�|t||�<q#W|S(N(R(t	iteritemsR(RR.R$tkeytvalue((s/usr/lib64/python2.7/copy.pyt_deepcopy_dict�s
 cCs(t|�|jt|j|�|j�S(N(R
tim_funcRtim_selftim_class(RR.((s/usr/lib64/python2.7/copy.pyt_deepcopy_methodscCsFy|t|�j|�Wn$tk
rA|g|t|�<nXdS(sMKeeps a reference to the object x in the memo.

    Because we remember objects by their id, we have
    to assure that possibly temporary objects are kept
    alive by referencing them.
    We store a reference at the id of the memo, which should
    normally not be used unless someone tries to deepcopy
    the memo itself...
    N(R(R2R5(RR.((s/usr/lib64/python2.7/copy.pyR-s

cCs�t|d�r|j|�St|d�rX|j�}t||�}|j|�}nt�}|j|_||t|�<t|d�r�|j�}n	|j}t||�}t|d�r�|j	|�n|jj
|�|S(NR'RRR(RR'RRRR R(RR!RR"(RR.R#R$R%((s/usr/lib64/python2.7/copy.pyt_deepcopy_insts"
		cCsmt|t�r|St|t�s(t�|dkr=i}nt|�}|dks[t�|d \}}|dkr�|d}ni}|dkr�|d}nd}|dkr�|d}	nd}	|r�t||�}n||�}
|
|t|�<|r�|rt||�}nt|
d�r9|
j	|�q�t|t�rit|�dkri|\}}nd}|dk	r�|
j
j|�n|dk	r�x-|j�D]\}}
t
|
||
�q�Wq�n|dk	rx6|D]+}|r�t||�}n|
j|�q�Wn|	dk	rixH|	D]=\}}
|rXt||�}t|
|�}
n|
|
|<q%Wn|
S(NiiiiR(iiii(t
isinstancetstrR8tAssertionErrorRR7RR(RRR!R"R;tsetattrR2(RtinfotdeepR.tntcallableR#R%tlistitertdictiterR$t	slotstateR<R=titem((s/usr/lib64/python2.7/copy.pyR2s\	


!
R cBseZRS((RR(((s/usr/lib64/python2.7/copy.pyR nsc
Cs	ddddddddgidd6dgig}t|�}||kGHtt|�}||kGHt|�}||kGHddd��Y}|d	�}|j|�t|�}||kGH|GH|GHt|�}||kGH|GH|GH|ji||d6|d
d6�t|�}ddl}t|j|�GHt|j|�GHt|j|�GHt|j|�GHt|�}ddl}t|j|�GHt|j|�GHt|j|�GHt|j|�GHd
tfd��Y}|idd6�}t|�}	||	fGHdS(Nilg��Q�	@txyzzytabctABCtCcBs2eZdd�Zd�Zd�Zdd�ZRS(cSs`d|_||_tdkr:ddl}|jd}nt}t|�|_|jj�dS(Nit__main__i����i(	R3targRtsystargvt__file__topentfptclose(tselfRURVtfile((s/usr/lib64/python2.7/copy.pyt__init__{s		cSsi|jd6|jd6S(NR3RU(R3RU(R\((s/usr/lib64/python2.7/copy.pyR�scSs1x*|j�D]\}}t|||�q
WdS(N(R;RG(R\R%R<R=((s/usr/lib64/python2.7/copy.pyR�scSs+|jt|j|��}|j|_|S(N(RRRUR3(R\R.tnew((s/usr/lib64/python2.7/copy.pyR'�sN(RRRR^RRR'(((s/usr/lib64/python2.7/copy.pyRSzs
		sargument sketchitxyzi����todictcBseZid�Zd�ZRS(cSsd|_tj||�dS(Nic(R3tdictR^(R\R0((s/usr/lib64/python2.7/copy.pyR^�s	cSstj|||�|jdS(N(Rbt__setitem__R3(R\tkR9((s/usr/lib64/python2.7/copy.pyRc�s(RRR^Rc(((s/usr/lib64/python2.7/copy.pyRa�stBtA(il(((RRtmapRR2treprRb(
tltl1RStctl2tl3RhRatoR((s/usr/lib64/python2.7/copy.pyt_testqsH
#RT(sComplexTypesUnicodeTypesCodeType((<t__doc__ttypestweakreftcopy_regRt	ExceptionRterrortorg.python.coreRtImportErrorRt__all__RRR0RR
tinttlongtfloattboolRER8t	frozensettxranget	ClassTypetBuiltinFunctionTypetEllipsistFunctionTypetreftttnameR
RtlistRbtsetRR&tInstanceTypeRR)R,tcomplext	NameErrortunicodeRtAttributeErrorR4R:R>RBt
MethodTypeR-RCRR RoR(((s/usr/lib64/python2.7/copy.pyt<module>1s�

	!
	
		
	
3
	













	
	
	

	
		
7	?