/usr/local/lib/python3.6/site-packages/dill/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/dill/__pycache__/temp.cpython-36.pyc (7302B)
3
8%Eg2 @ s d Z ddddddddd g Zd
dlZdd
lmZ ejddd Zdd Zdd Zdd Z dd Z
dd Zdd Zdd Z
dd Zdd Z[dS )zb
Methods for serialized objects (or source code) stored in temporary files
and file-like objects.
dump_sourcedump
dumpIO_sourcedumpIOload_sourceload
loadIO_sourceloadIOcapture N )PY3stdoutc
c sb ddl }trddlm} nddlm} t|| }t|| | zt|| V W dt|| | X dS )zbuilds a context that temporarily replaces the given stream name
>>> with capture('stdout') as out:
... print ("foo!")
...
>>> print (out.getvalue())
foo!
r
N)StringIO)sysr ior getattrsetattr)streamr r orig r 3/usr/local/lib/python3.6/site-packages/dill/temp.pyr s
c C s dd l }|j| d S )Nr
)codecslatin_1_encode)xr r r r b/ s r c
K s |j dd}|j dd}t| d| }t|fd|i|j }|s|j j d j }|d dkrx|j d }td | |d }i }t|| t d
| |} | S )
aC load 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 r
z#NAME:zunknown name for code: %sz%sr )
popr openreadstrip
splitlinessplitIOErrorexeceval)
filekwdsr r fnamesourcetagstublocal_r r r r 3 s
c K s ddl m}m} ddl}|jdd |jdd}t|p>|| }d| }|jf dd i|}|jtdj || |d
|g |j
|S )aM write 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 !
r )
importablegetnamer
Nsuffix r z
#NAME: %s
z.py)r )r, r1 r2 tempfiler strNamedTemporaryFilewriter joinflush)objectr* r1 r2 r5 r r r) r r r r O s c K s: ddl }|jdd}t| d| }|jt|fd|i|S )zload an object that was stored with dill.temp.dump
file: filehandle
mode: mode to open the file, one of: {'r', 'rb'}
>>> dumpfile = dill.temp.dump([1, 2, 3, 4, 5])
>>> dill.temp.load(dumpfile)
[1, 2, 3, 4, 5]
r
Nr rbr )dillr r r r! )r) r* pickler r r r r r { s
c K s4 ddl }ddl}|jf |}|j| | |j |S )aE dill.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
N)r= r5 r7 r r: )r; r* r> r5 r) r r r r s c K sN ddl }trddlm} nddlm} t| d| }|| kr@| }|j||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
N)BytesIO)r getvalue)r= r r r? r r r )bufferr* r> r valuer r r r s c K sD ddl }trddlm} nddlm} | }|j| | |j |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
N)r? )r )r= r r r? r r r: )r; r* r> r r) r r r r s c K s |j dd}t| d| }|| kr&| }tr2|j }|sv|j j d j }|d dkrn|j d }td| |d
}i }t|| t d| |}|S )a load 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
r Nr@ r r
z#NAME:zunknown name for code: %sz%sr r )
r r r decoder# r$ r% r&