eaiovnaovbqoebvqoeavibavo B  f @sdZddlmZddlmZddlmZmZmZddlm Z ddl m Z ddl Z ddl m Z dd lmZmZddlZddlZddlZddlZd d d d dddddg ZeefZdZdddddddgZdZdZGdd d eZGdd d eZGdd d eZ Gdd d eZ!ydd!l"m#Z#Wne$k r2dZ#YnXd"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+d)Z,d*Z-d+Z.d,Z/d-Z0d.Z1d/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9ZdZAd?ZBd@ZCdAZDdBZEdCZFdDZGdEZHdFZIdGZJdHZKdIZLdJZMdKZNdLZOdMZPdNZQdOZRdPZSdQZTdRZUdSZVdTZWdUZXdVZYdWZZdXZ[eKeUeVeWgZ\dYZ]dZZ^d[Z_d\Z`d]Zad^Zbd_Zcd`ZddaZedbZfdcZgddZheidedfejDGdgdhdhZkGdidjdjZldkdlZmdmdnZndodpZodqdrZpGdsdtdtZqGdudvdvZrddwdxdydzZsddwdxd{d|Ztdwd}d~dddZudwd}d~dddZvy0ddlwmZmZm Z mxZxmyZymzZzm{Z{m|Z|m}Z}Wn4e$k rbeqerZxZyeseteuevf\ZzZ{Z|Z}YnXddZ~edkrddlZejddZejdeddddejdddddejddddeZejre~n>ejsen,ddlZx"ejD]Ze|eZeeqWdS)aCreate portable serialized representations of Python objects. See module copyreg for a mechanism for registering custom picklers. See module pickletools source for extensive comments. Classes: Pickler Unpickler Functions: dump(object, file) dumps(object) -> string load(file) -> object loads(string) -> object Misc variables: __version__ format_version compatible_formats ) FunctionType)dispatch_table)_extension_registry_inverted_registry_extension_cache)islice)partialN)maxsize)packunpack PickleError PicklingErrorUnpicklingErrorPickler Unpicklerdumpdumpsloadloadsz4.0z1.0z1.1z1.2z1.3z2.0z3.0c@seZdZdZdS)r z6A common base class for the other pickling exceptions.N)__name__ __module__ __qualname____doc__rr+/opt/alt/python37/lib64/python3.7/pickle.pyr @sc@seZdZdZdS)r z]This exception is raised when an unpicklable object is passed to the dump() method. N)rrrrrrrrr Dsc@seZdZdZdS)raThis exception is raised when there is a problem unpickling an object, such as a security violation. Note that other exceptions may also be raised during unpickling, including (but not necessarily limited to) AttributeError, EOFError, ImportError, and IndexError. N)rrrrrrrrrKsc@seZdZddZdS)_StopcCs ||_dS)N)value)selfrrrr__init__Ysz_Stop.__init__N)rrrr rrrrrXsr) PyStringMap(.012FIJKLMNPQRSTUVXabcd}eghijl]opqrst)uGsI01 sI00 BCcCsg|]}td|r|qS)z[A-Z][A-Z0-9_]+$)rematch).0xrrr srgc@sFeZdZdZdZddZddZddZdd d Zd d Z ddZ dS)_FramerricCs||_d|_dS)N) file_write current_frame)rrirrrr sz_Framer.__init__cCst|_dS)N)ioBytesIOrj)rrrr start_framingsz_Framer.start_framingcCs*|jr&|jdkr&|jddd|_dS)NrT)force)rjtell commit_frame)rrrr end_framings z_Framer.end_framingFcCsf|jrb|j}||jks|rb|}|j}t||jkrP|ttdt|||t |_dS)Nzz&Can't get local attribute {!r} on {!r}z Can't get attribute {!r} on {!r})splitAttributeErrorformatgetattr)objnameZsubpathparentrrr _getattribute!s rc Cszt|dd}|dk r|Sx\ttjD]J\}}|dks(|dkrBq(yt||d|krZ|SWq(tk rpYq(Xq(WdS)z$Find the module an object belong to.rN__main__r)rlistsysmodulesitemsrr)rr module_namemodulerrr whichmodule.s  rcCsh|dkr dS|d?d}|j|ddd}|dkrd|dkrd|dd krd|d d @dkrd|d d}|S) aEncode a long to a two's complement little-endian binary string. Note that 0 is a special case, returning an empty string, to save a byte in the LONG1 pickling context. >>> encode_long(0) b'' >>> encode_long(255) b'\xff\x00' >>> encode_long(32767) b'\xff\x7f' >>> encode_long(-256) b'\x00\xff' >>> encode_long(-32768) b'\x00\x80' >>> encode_long(-128) b'\x80' >>> encode_long(127) b'\x7f' >>> rrrlittleT) byteordersignedrN) bit_lengthto_bytes)rfnbytesresultrrr encode_long?s rcCstj|dddS)a\Decode a long from a two's complement little-endian binary string. >>> decode_long(b'') 0 >>> decode_long(b"\xff\x00") 255 >>> decode_long(b"\xff\x7f") 32767 >>> decode_long(b"\x00\xff") -256 >>> decode_long(b"\x00\x80") -32768 >>> decode_long(b"\x80") -128 >>> decode_long(b"\x7f") 127 rT)rr)int from_bytes)rxrrr decode_long]src@sheZdZd7ddddZddZdd Zd d Zd d ZddZd8ddZ ddZ ddZ d9ddZ iZ ddZee ed<ddZee e<ddZee e<ddZee e<d d!Zee e<d"d#Zee e<d$d%Zee e<d&d'Zee e<d(Zd)d*Zd+d,Z e e e!<e"dk re e e"<d-d.Z#d/d0Z$e$e e%<d1d2Z&e&e e'<d:d3d4Z(d5d6Z)e(e e*<e)e e<dS);_PicklerNT) fix_importscCs|dkr t}|dkrt}n"d|kr.tksy |tt|ddWntk r\tdYnXdS)NF)rrrz2persistent IDs in protocol 0 must be ASCII strings) rrry BINPERSIDPERSIDrrUnicodeEncodeErrorr )rrrrrr+s  z_Pickler.save_persc Cst|tstdt|s"td|j}|j}t|dd} |jdkr| dkr|\} }} t| dsntd | |dk r| |j k rtd | |jd kr|| |||| |t n,t | j | f|| }|||d |tn|jdkr^| d kr^|d } t| dstd|dk r8| |j k r8td|dd}|| |||tn|||||t|dk rt||jkr|t||jt|d n |||dk r|||dk r|||dk r|||tdS)Nz'args from save_reduce() must be a tuplez(func from save_reduce() must be callablerr __newobj_ex____new__z#args[0] from {} args has no __new__z(args[0] from {} args has the wrong classrr __newobj__rz+args[0] from __newobj__ args has no __new__z0args[0] from __newobj__ args has the wrong classr)rrr callablerryrrrrr NEWOBJ_EXrrREDUCENEWOBJrrPOPrr_batch_appends_batch_setitemsBUILD) rfuncargsstateZ listitemsZ dictitemsrrryZ func_nameclskwargsrrrr7sd           "      z_Pickler.save_reducecCs|tdS)N)ryNONE)rrrrr save_nonesz_Pickler.save_nonecCs4|jdkr||rtntn||r*tntdS)Nr)rryNEWTRUENEWFALSETRUEFALSE)rrrrr save_bools z_Pickler.save_boolcCs.|jr~|dkrN|dkr.|ttd|dS|dkrN|ttd|dSd|krbdkr~nn|ttd|dS|jd krt|}t|}|d kr|t td||n|t td||dSd|krdkrnn|t t | d d n|tt | d d dS)Nrrzdrr)rryBINFLOATr FLOATrr)rrrrr save_floatsz_Pickler.save_floatcCs|jdkr@|s |jtd|dn|jtjt|ddf|ddSt|}|dkrj|tt d||nf|dkr|jdkr| t t d ||n<||j j kr| tt d ||n|tt d ||||dS) Nrr)rlatin1rzdSq>WdS)Nrr) rryrAPPENDiterrr _BATCHSIZErtrAPPENDS)rrrryrfittmprrrrr9s*       z_Pickler._batch_appendscCs<|jr|tn|tt||||dS)N)rry EMPTY_DICTrDICTrrr)rrrrr save_dictTs   z_Pickler.save_dictc Cs|j}|j}|js@x(|D] \}}|||||tqWdSt|}xtt||j}t|}|dkr|t x |D]\}}||||qxW|t n(|r|d\}}|||||t||jkrJdSqJWdS)Nrr) rryrSETITEMr(rrr)rtrSETITEMS) rrrrykvr+r,rrrrras2     z_Pickler._batch_setitemscCs|j}|j}|jdkr0|jtt|f|ddS|t||t|}xXtt ||j }t |}|dkr|t x|D] }||qzW|t ||j krLdSqLWdS)Nr)rr)rryrrsetr EMPTY_SETrr(rr)rtrADDITEMS)rrrryr+Zbatchritemrrrsave_sets$     z_Pickler.save_setcCs|j}|j}|jdkr0|jtt|f|ddS|tx|D] }||q>Wt||jkr|t | |jt|ddS|t | |dS)Nr)rr) rryrr frozensetrrrrr"r FROZENSETr)rrrryr7rrrsave_frozensets    z_Pickler.save_frozensetc Csd|j}|j}|dkr t|dd}|dkr.|j}t||}y(t|ddtj|}t||\}}Wn.t t t fk rt d|||fdYnX||k rt d|||f|j dkr&t||f} | r&| dkst| dkr|ttd| n0| d kr|ttd | n|ttd | dS|d d} ||krB| }|j d krl|||||tn||k r|t|| fn|j dkr|tt|ddt|ddn|jrtj} tj} ||f| kr| ||f\}}n|| kr| |}y(|tt|ddt|ddWn,tk rTt d|||j fdYnX| |dS)Nrr)levelz(Can't pickle %r: it's not found as %s.%sz2Can't pickle %r: it's not the same object as %s.%srrzd?Z7e7ee8d<d@dAZ9e9ee:d<dBdCZ;e;eed<dFdGZ?e?ee@d<dHdIZAeAeeBd<dJdKZCeCeeDd<dLdMZEeEeeFd<dNdOZGeGeeHd<dPdQZIeIeeJd<dRdSZKeKeeLd<dTdUZMeMeeNd<dVdWZOeOeePd<dXdYZQeQeeRd<dZd[ZSd\d]ZTeTeeUd<d^d_ZVeVeeWd<d`daZXeXeeYd<dbdcZZeZee[d<dddeZ\e\ee]d<dfdgZ^e^ee_d<dhdiZ`e`eead<djdkZbebeecd<dldmZdedeeed<dndoZfdpdqZgdrdsZheheeid<dtduZjejeekd<dvdwZleleemd<dxdyZneneeod<dzd{Zpepeeqd<d|d}Zrereesd<d~dZteteeud<ddZveveewd<ddZxexeeyd<ddZzezee{d<ddZ|e|ee}d<ddZ~e~eed<ddZeeed<ddZeeed<ddZeeed<ddZeeed<ddZeeed<ddZeeed<ddZeeed<dS) _UnpicklerTASCIIstrict)rencodingerrorscCs2|j|_|j|_i|_||_||_d|_||_dS)aThis takes a binary file for reading a pickle data stream. The protocol version of the pickle is detected automatically, so no proto argument is needed. The argument *file* must have two methods, a read() method that takes an integer argument, and a readline() method that requires no arguments. Both methods should return bytes. Thus *file* can be a binary file object opened for reading, an io.BytesIO object, or any other custom object that meets this interface. The file-like object must have two methods, a read() method that takes an integer argument, and a readline() method that requires no arguments. Both methods should return bytes. Thus file-like object can be a binary file object opened for reading, a BytesIO object, or any other custom object that meets this interface. Optional keyword arguments are *fix_imports*, *encoding* and *errors*, which are used to control compatibility support for pickle stream generated by Python 2. If *fix_imports* is True, pickle will try to map the old Python 2 names to the new names used in Python 3. The *encoding* and *errors* tell pickle how to decode 8-bit string instances pickled by Python 2; these default to 'ASCII' and 'strict', respectively. *encoding* can be 'bytes' to read theses 8-bit string instances as bytes objects. rN) r_file_readliner _file_readrrPrQrr)rrrrPrQrrrr sz_Unpickler.__init__c Cst|dstd|jjft|j|j|_|jj|_|jj |_ g|_ g|_ |j j |_ d|_ |j}|j}y8x2|d}|s|tt|tst||d|qlWWn$tk r}z|jSd}~XYnXdS)zRead a pickled object representation from the open file. Return the reconstituted object hierarchy specified in the file. rSz4Unpickler.__init__() was not called by %s.__init__()rrN)rrrrr|rSrR _unframerrr metastackstackappendrrEOFErrorr bytes_typesrrr)rrrkeyZstopinstrrrr's*    z_Unpickler.loadcCs |j}|j|_|jj|_|S)N)rVrUpoprW)rrrrrpop_markEs  z_Unpickler.pop_markcCs tddS)Nz%unsupported persistent id encountered)r)rrrrrpersistent_loadKsz_Unpickler.persistent_loadcCs:|dd}d|kr"tks0ntd|||_dS)Nrrzunsupported pickle protocol: %d)rrrr)rrrrr load_protoPs z_Unpickler.load_protorcCs8td|d\}|tjkr(td||j|dS)Nz sys.maxsize: %d)r rrr rrTr)rrrrrrWs  z_Unpickler.load_framecCsLy|ddd}Wntk r6tdYnX|||dS)Nrrz2persistent IDs in protocol 0 must be ASCII strings)rdecodeUnicodeDecodeErrorrrWr])rrrrr load_persid^s  z_Unpickler.load_persidcCs|j}|||dS)N)rVr[rWr])rrrrrload_binpersidgs z_Unpickler.load_binpersidcCs|ddS)N)rW)rrrr load_nonelsz_Unpickler.load_nonecCs|ddS)NF)rW)rrrr load_falsepsz_Unpickler.load_falsecCs|ddS)NT)rW)rrrr load_truetsz_Unpickler.load_truecCsL|}|tddkrd}n |tddkr4d}n t|d}||dS)NrFTr)rrrrrW)rrxvalrrrload_intxs z_Unpickler.load_intcCs|td|dddS)Nztd|d\}|dkr"td||}|t|dS)Nzdr_r)rWr r)rrrr load_binfloatsz_Unpickler.load_binfloatcCs"|jdkr|S||j|jSdS)Nr )rPr`rQ)rrrrr_decode_strings z_Unpickler._decode_stringcCsl|dd}t|dkrF|d|dkrF|ddkrF|dd}ntd||t|ddS)Nrrrs"'rz)the STRING opcode argument must be quoted)rrtrrWrrr  escape_decode)rrxrrr load_strings (z_Unpickler.load_stringcCs@td|d\}|dkr"td||}|||dS)Nz*sz(_Unpickler.load_dict..rr)r\rangertrW)rdr)rr load_dict(s z_Unpickler.load_dictc Cs|st|trt|drjy ||}Wqttk rf}z$td|jt|ftdWdd}~XYqtXn ||}| |dS)NZ__getinitargs__zin constructor for %s: %sr) rrrrrrrexc_inforrW)rklassrrerrrrr _instantiate4s  0 z_Unpickler._instantiatecCsL|ddd}|ddd}|||}|||dS)Nrr)rr` find_classrr\)rrrrrrr load_inst@s z_Unpickler.load_instcCs"|}|d}|||dS)Nr)r\r[r)rrrrrrload_objGs z_Unpickler.load_objcCs2|j}|j}|j|f|}||dS)N)rVr[rrW)rrrrrrr load_newobjNs  z_Unpickler.load_newobjcCs>|j}|j}|j}|j|f||}||dS)N)rVr[rrW)rrrrrrrrload_newobj_exUs    z_Unpickler.load_newobj_excCsF|ddd}|ddd}|||}||dS)Nrzutf-8)rr`rrW)rrrrrrr load_global]s z_Unpickler.load_globalcCsJ|j}|j}t|tk s,t|tk r4td||||dS)NzSTACK_GLOBAL requires str)rVr[rrrrWr)rrrrrrload_stack_globalds   z_Unpickler.load_stack_globalcCs|dd}||dS)Nrr)r get_extension)rrGrrr load_ext1lsz_Unpickler.load_ext1cCs td|d\}||dS)Nzs   r) r r rrrrrrrcCsddl}|S)Nr)doctestZtestmod)rrrr_testWsrrz$display contents of the pickle files)Z description pickle_filebr*zthe pickle file)rnargshelpz-tz--test store_truezrun self-test suite)actionrz-vz)run verbosely; only affects self-test run)N)N)rtypesrcopyregrrrr itertoolsr functoolsrrr Zstructr r rcrkr rF__all__r  bytearrayrYZformat_versionZcompatible_formatsrr Exceptionr r rrZorg.python.corer!r>rrrr"rr rrrrrrrrrrrrrrr'rrEr.r-r*rrrrr%r$rrrrr0r rr1rrrrrr@rArBrrrrrrrr!rrrrrr5r6r:rrDrrvrdirrhr|rrrrrrMrrrr_picklerrrrrrrrargparseArgumentParserparser add_argumentZFileType parse_argsrZtestrZ print_helpZpprintrwrrrrrs.        ?* 40