MCPcopy Index your code
hub / github.com/RustPython/RustPython / _candidate_tempdir_list

Function _candidate_tempdir_list

Lib/tempfile.py:156–181  ·  view source on GitHub ↗

Generate a list of candidate temporary directories which _get_default_tempdir will try.

()

Source from the content-addressed store, hash-verified

154 return ''.join(self.rng.choices(self.characters, k=8))
155
156def _candidate_tempdir_list():
157 """Generate a list of candidate temporary directories which
158 _get_default_tempdir will try."""
159
160 dirlist = []
161
162 # First, try the environment.
163 for envname in 'TMPDIR', 'TEMP', 'TMP':
164 dirname = _os.getenv(envname)
165 if dirname: dirlist.append(dirname)
166
167 # Failing that, try OS-specific locations.
168 if _os.name == 'nt':
169 dirlist.extend([ _os.path.expanduser(r'~\AppData\Local\Temp'),
170 _os.path.expandvars(r'%SYSTEMROOT%\Temp'),
171 r'c:\temp', r'c:\tmp', r'\temp', r'\tmp' ])
172 else:
173 dirlist.extend([ '/tmp', '/var/tmp', '/usr/tmp' ])
174
175 # As a last resort, the current directory.
176 try:
177 dirlist.append(_os.getcwd())
178 except (AttributeError, OSError):
179 dirlist.append(_os.curdir)
180
181 return dirlist
182
183def _get_default_tempdir(dirlist=None):
184 """Calculate the default directory to use for temporary files.

Callers 1

_get_default_tempdirFunction · 0.85

Calls 3

expanduserMethod · 0.80
appendMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected