MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / get_temp_dir

Function get_temp_dir

src/commoncode/fileutils.py:100–122  ·  view source on GitHub ↗

Return the path to a new existing unique temporary directory, created under the `base_dir` base directory using the `prefix` prefix. If `base_dir` is not provided, use the 'SCANCODE_TMP' env var or the system temp directory. WARNING: do not change this code without changing sca

(base_dir=_base_temp_dir, prefix="")

Source from the content-addressed store, hash-verified

98
99
100def get_temp_dir(base_dir=_base_temp_dir, prefix=""):
101 """
102 Return the path to a new existing unique temporary directory, created under
103 the `base_dir` base directory using the `prefix` prefix.
104 If `base_dir` is not provided, use the 'SCANCODE_TMP' env var or the system
105 temp directory.
106
107 WARNING: do not change this code without changing scancode_config.py too
108 """
109
110 has_base = bool(base_dir)
111 if not has_base:
112 base_dir = os.getenv("SCANCODE_TMP")
113 if not base_dir:
114 base_dir = tempfile.gettempdir()
115
116 if not os.path.exists(base_dir):
117 create_dir(base_dir)
118
119 if not has_base:
120 prefix = "scancode-tk-"
121
122 return tempfile.mkdtemp(prefix=prefix, dir=base_dir)
123
124
125#

Callers 2

get_codebase_cache_dirFunction · 0.90
executeFunction · 0.90

Calls 3

boolFunction · 0.85
create_dirFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected