�`^c@s�dZddlZddlZddlmZdefd��YZeZyddlm Z Wne
k
rwdZ nXdddgZd �Z
iZZd
�Zx]ed�eeeeeeeeeejejee�ejejfD]Zeee<q�x9dD]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/sys/lib/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/sys/lib/python2.7/copy.pyRBs$
cCs|S(N((R((s/sys/lib/python2.7/copy.pyt_copy_immutableestComplexTypetUnicodeTypetCodeTypecCst|�|�S(N(R
(R((s/sys/lib/python2.7/copy.pyt_copy_with_constructorqscCs
|j�S(N(R(R((s/sys/lib/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/sys/lib/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(
RtidRR
t_deepcopy_dispatcht
issubclasst TypeErrort_deepcopy_atomicR
RRRt_keep_alive(
Rtmemot_niltdR$RRtisscRR((s/sys/lib/python2.7/copy.pyR�sD
cCs|S(N((RR.((s/sys/lib/python2.7/copy.pyR,�scCsAg}||t|�<x$|D]}|jt||��qW|S(N(R(tappendR(RR.R$ta((s/sys/lib/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/sys/lib/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/sys/lib/python2.7/copy.pyt_deepcopy_dict�s
cCs(t|�|jt|j|�|j�S(N(R
tim_funcRtim_selftim_class(RR.((s/sys/lib/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/sys/lib/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/sys/lib/python2.7/copy.pyt_deepcopy_insts"
cCsFt|t�r|S|dkr(i}nt|�}|d \}}|dkr]|d}ni}|dkr||d}nd}|dkr�|d} nd} |r�t||�}n||�}
|
|t|�<|r�|r�||�}nt|
d�r|
j|�q�t|t�rBt|�dkrB|\}}nd}|dk rg|
j j
|�n|dk r�x-|j�D]\}}
t|
||
�q�Wq�n|dk r�6|D]+}|r�t||�}n|
j
|�q�Wn| dk rBxH| D]=\}}
|r1t||�}t|
|�}
n|
|
|<q�|
S(NiiiR(t
isinstancetstrRR7RR(RRR8R!R"R;tsetattrR2(RtinfotdeepR.tntcallableR#R%tlistitertdictiterR$t slotstateR<R=titem((s/sys/lib/python2.7/copy.pyR2sX
!
R cBseZRS((RR(((s/sys/lib/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|�}ddl}t|j|�GHt|j|�GHt|j|�GHt|j|�GHt|�}ddl}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(tselfRTRUtfile((s/sys/lib/python2.7/copy.pyt__init__{s cSsi|jd6|jd6S(NR3RT(R3RT(R[((s/sys/lib/python2.7/copy.pyR�scSs1x*|j�D]\}}t|||�q
WdS(N(R;RF(R[R%R<R=((s/sys/lib/python2.7/copy.pyR�scSs+|jt|j|��}|j|_|S(N(RRRTR3(R[R.tnew((s/sys/lib/python2.7/copy.pyR'�sN(RRRR]RRR'(((s/sys/lib/python2.7/copy.pyRRzs
sargument sketchitxyzi�todictcBseZid�Zd�ZRS(cSsd|_tj||�dS(Nic(R3tdictR](R[R0((s/sys/lib/python2.7/copy.pyR]�s cSstj|||�|jdS(N(Rat__setitem__R3(R[tkR9((s/sys/lib/python2.7/copy.pyRb�s(RRR]Rb(((s/sys/lib/python2.7/copy.pyR`�stBtA(il(((RRtmapRR2treprRa(
tltl1RRtctl2tl3RgR`toR((s/sys/lib/python2.7/copy.pyt_testqsH
#RS(sComplexTypesUnicodeTypesCodeType((<t__doc__ttypestweakreftcopy_regRt ExceptionRterrortorg.python.coreRtImportErrorRt__all__RRR0RR
tinttlongtfloattboolRER8t frozensettxranget ClassTypetBuiltinFunctionTypetEllipsistFunctionTypetreftttnameR
RtlistRatsetRR&tInstanceTypeRR)R,tcomplext NameErrortunicodeRtAttributeErrorR4R:R>RBt
MethodTypeR-RCRR RnR(((s/sys/lib/python2.7/copy.pyt<module>1s�
!
3
7 ?
|