bg[tdZgdZddlZejddZdZdZdZd Zd Z d Z d Z d Z dZ [dS)zb Methods for serialized objects (or source code) stored in temporary files and file-like objects. ) dump_sourcedump dumpIO_sourcedumpIO load_sourceload loadIO_sourceloadIOcaptureNstdoutc#Kddl}ddlm}t||}t ||| t||Vt |||dS#t |||wxYw)zbuilds a context that temporarily replaces the given stream name >>> with capture('stdout') as out: ... print ("foo!") ... >>> print (out.getvalue()) foo! r N)StringIO)sysiorgetattrsetattr)streamrrorigs Z/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/dill/temp.pyr r sJJJ 3  D C$$$#c6"""""VT"""""VT""""s AA/c@ddl}||dS)Nr )codecslatin_1_encode)xrs rbr+s$MMM   # #A &&c |dd}|dd}t|d|}t|fd|i|}|s~|d}|ddkr,|d}td |z|d}i}t||td |z|} | S) aCload an object that was stored with dill.temp.dump_source file: filehandle alias: string name of stored object mode: mode to open the file, one of: {'r', 'rb'} >>> f = lambda x: x**2 >>> pyfile = dill.temp.dump_source(f, alias='_f') >>> _f = dill.temp.load_source(pyfile) >>> _f(4) 16 aliasNmodernamer #NAME:unknown name for code: %s%s) popropenreadstrip splitlinessplitIOErrorexeceval) filekwdsrrfnamesourcetagstublocal_s rrr/s HHWd # #E 88FC D D&$ ' 'E % + +d +d + + 0 0 2 2F llnn''))"-3355 q6X  $$&&q)D5<== =B E TE\5!!A Hrc ddlm}m}ddl}|dd|dd|d d}t |p ||}d |z}|jd dd i|}|td ||| |g| |S)aMwrite object source to a NamedTemporaryFile (instead of dill.dump) Loads with "import" or "dill.temp.load_source". Returns the filehandle. >>> f = lambda x: x**2 >>> pyfile = dill.temp.dump_source(f, alias='_f') >>> _f = dill.temp.load_source(pyfile) >>> _f(4) 16 >>> f = lambda x: x**2 >>> pyfile = dill.temp.dump_source(f, dir='.') >>> modulename = os.path.basename(pyfile.name).split('.py')[0] >>> exec('from %s import f as _f' % modulename) >>> _f(4) 16 Optional kwds: If 'alias' is specified, the object will be renamed to the given string. If 'prefix' is specified, the file name will begin with that prefix, otherwise a default prefix is used. If 'dir' is specified, the file will be created in that directory, otherwise a default directory is used. If 'text' is specified and true, the file is opened in text mode. Else (the default) the file is opened in binary mode. On some operating systems, this makes no difference. NOTE: Keep the return value for as long as you want your file to exist !  importablegetnamer NdeleteTsuffixr #NAME: %s z.pyr) r1r9r:tempfile setdefaultr%strNamedTemporaryFilewriterjoinflush)objectr/r9r:rArr r.s rrrKs@,+++++++OOOOOHd###HHXr HHWb ! !E u:: (D T !D &8 & < >> dumpfile = dill.temp.dump([1, 2, 3, 4, 5]) >>> dill.temp.load(dumpfile) [1, 2, 3, 4, 5] r Nrrbr )dillr%rrr&)r.r/picklerr s rrrxs[ 88FD ! !D 4 & &D ;;tD44t4t44 5 55rc ddl}ddl}|dd|jdi|}|||||S)aEdill.dump of object to a NamedTemporaryFile. Loads with "dill.temp.load". Returns the filehandle. >>> dumpfile = dill.temp.dump([1, 2, 3, 4, 5]) >>> dill.temp.load(dumpfile) [1, 2, 3, 4, 5] Optional kwds: If 'suffix' is specified, the file name will end with that suffix, otherwise there will be no suffix. If 'prefix' is specified, the file name will begin with that prefix, otherwise a default prefix is used. If 'dir' is specified, the file will be created in that directory, otherwise a default directory is used. If 'text' is specified and true, the file is opened in text mode. Else (the default) the file is opened in binary mode. On some operating systems, this makes no difference. NOTE: Keep the return value for as long as you want your file to exist ! r Nr;Tr@)rKrArBrDrrG)rHr/rLrAr.s rrrsk0OOOOOHd### &8 & . . . .D KKJJLLL Krc ddl}ddlm}t|d|}||kr |}|||S)zload an object that was stored with dill.temp.dumpIO buffer: buffer object >>> dumpfile = dill.temp.dumpIO([1, 2, 3, 4, 5]) >>> dill.temp.loadIO(dumpfile) [1, 2, 3, 4, 5] r NBytesIOgetvalue)rKrrPrr)bufferr/rLrvalues rr r s`&&&&&& FJ / /E  ;;xx ' ''rc ddl}ddlm}|}|||||S)zdill.dump of object to a buffer. Loads with "dill.temp.loadIO". Returns the buffer object. >>> dumpfile = dill.temp.dumpIO([1, 2, 3, 4, 5]) >>> dill.temp.loadIO(dumpfile) [1, 2, 3, 4, 5] r NrO)rKrrPrrG)rHr/rLrr.s rrrsS&&&&&& 8::D KKJJLLL Krc |dd}t|d|}||kr |}|}|s~|d}|ddkr,|d}t d|z|d}i}t||td|z|}|S) aload an object that was stored with dill.temp.dumpIO_source buffer: buffer object alias: string name of stored object >>> f = lambda x:x**2 >>> pyfile = dill.temp.dumpIO_source(f, alias='_f') >>> _f = dill.temp.loadIO_source(pyfile) >>> _f(4) 16 rNrQr!r r"r#r$) r%rdecoder(r)r*r+r,r-)rRr/rr1r2r3r4r5s rrrs HHWd # #E VZ 0 0F &&(( ]]__F llnn''))"-3355 q6X  $$&&q)D5<== =B E TE\5!!A Hrc Lddlm}m}ddlm}|dd}t |p ||}d|z}|}|td ||||g| |S) apwrite object source to a buffer (instead of dill.dump) Loads by with dill.temp.loadIO_source. Returns the buffer object. >>> f = lambda x:x**2 >>> pyfile = dill.temp.dumpIO_source(f, alias='_f') >>> _f = dill.temp.loadIO_source(pyfile) >>> _f(4) 16 Optional kwds: If 'alias' is specified, the object will be renamed to the given string. r7r8r rOrr=r>r?) r1r9r:rrPr%rCrErrFrG)rHr/r9r:rrr r.s rrrs,+++++++&&&&&& HHWb ! !E u:: (D T !D 8::DJJq**V5999$?@@AABBBJJLLL Kr)r )__doc____all__ contextlibcontextmanagerr rrrrrr rrrr@rrr\s    ####('''   8+++Z 6 6 6@ ( ( (      62JJr