/
opt
/
imh-python
/
lib
/
python3.9
/
site-packages
/
IPython
/
utils
/
/opt/imh-python/lib/python3.9/site-packages/IPython/utils
mkdir
upload
Name
Size
Mode
Actions
tests/
-
0755
rm
__pycache__/
-
0755
rm
capture.py
5161
0644
edit
dl
rm
colorable.py
786
0644
edit
dl
rm
coloransi.py
6972
0644
edit
dl
rm
contexts.py
1619
0644
edit
dl
rm
daemonize.py
200
0644
edit
dl
rm
data.py
1015
0644
edit
dl
rm
decorators.py
2680
0644
edit
dl
rm
dir2.py
2232
0644
edit
dl
rm
docs.py
86
0644
edit
dl
rm
encoding.py
2843
0644
edit
dl
rm
eventful.py
138
0644
edit
dl
rm
frame.py
3048
0644
edit
dl
rm
generics.py
706
0644
edit
dl
rm
importstring.py
1050
0644
edit
dl
rm
io.py
4631
0644
edit
dl
rm
ipstruct.py
11856
0644
edit
dl
rm
jsonutil.py
148
0644
edit
dl
rm
localinterfaces.py
169
0644
edit
dl
rm
log.py
123
0644
edit
dl
rm
module_paths.py
2327
0644
edit
dl
rm
openpy.py
3417
0644
edit
dl
rm
path.py
11937
0644
edit
dl
rm
process.py
1878
0644
edit
dl
rm
py3compat.py
1602
0644
edit
dl
rm
PyColorize.py
10875
0644
edit
dl
rm
sentinel.py
421
0644
edit
dl
rm
shimmodule.py
2669
0644
edit
dl
rm
signatures.py
474
0644
edit
dl
rm
strdispatch.py
1838
0644
edit
dl
rm
sysinfo.py
4365
0644
edit
dl
rm
syspathcontext.py
1952
0644
edit
dl
rm
tempdir.py
1867
0644
edit
dl
rm
terminal.py
3206
0644
edit
dl
rm
text.py
24428
0644
edit
dl
rm
timing.py
4275
0644
edit
dl
rm
tokenutil.py
5083
0644
edit
dl
rm
traitlets.py
143
0644
edit
dl
rm
tz.py
1380
0644
edit
dl
rm
ulinecache.py
684
0644
edit
dl
rm
version.py
1223
0644
edit
dl
rm
wildcard.py
4612
0644
edit
dl
rm
_process_cli.py
2020
0644
edit
dl
rm
_process_common.py
7003
0644
edit
dl
rm
_process_posix.py
8666
0644
edit
dl
rm
_process_win32.py
6132
0644
edit
dl
rm
_process_win32_controller.py
21329
0644
edit
dl
rm
_sysinfo.py
45
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
Edit:
/opt/imh-python/lib/python3.9/site-packages/IPython/utils/tempdir.py
(1867B)
""" This module contains classes - NamedFileInTemporaryDirectory, TemporaryWorkingDirectory. These classes add extra features such as creating a named file in temporary directory and creating a context manager for the working directory which is also temporary. """ import os as _os from pathlib import Path from tempfile import TemporaryDirectory class NamedFileInTemporaryDirectory(object): def __init__(self, filename, mode="w+b", bufsize=-1, add_to_syspath=False, **kwds): """ Open a file named `filename` in a temporary directory. This context manager is preferred over `NamedTemporaryFile` in stdlib `tempfile` when one needs to reopen the file. Arguments `mode` and `bufsize` are passed to `open`. Rest of the arguments are passed to `TemporaryDirectory`. """ self._tmpdir = TemporaryDirectory(**kwds) path = Path(self._tmpdir.name) / filename encoding = None if "b" in mode else "utf-8" self.file = open(path, mode, bufsize, encoding=encoding) def cleanup(self): self.file.close() self._tmpdir.cleanup() __del__ = cleanup def __enter__(self): return self.file def __exit__(self, type, value, traceback): self.cleanup() class TemporaryWorkingDirectory(TemporaryDirectory): """ Creates a temporary directory and sets the cwd to that directory. Automatically reverts to previous cwd upon cleanup. Usage example: with TemporaryWorkingDirectory() as tmpdir: ... """ def __enter__(self): self.old_wd = Path.cwd() _os.chdir(self.name) return super(TemporaryWorkingDirectory, self).__enter__() def __exit__(self, exc, value, tb): _os.chdir(self.old_wd) return super(TemporaryWorkingDirectory, self).__exit__(exc, value, tb)
Save
cmd:
run