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

Method get_temp_file

src/commoncode/testcase.py:139–153  ·  view source on GitHub ↗

Return a unique new temporary file location to a non-existing temporary file that can safely be created without a risk of name collision.

(self, extension=None, dir_name="td", file_name="tf")

Source from the content-addressed store, hash-verified

137 return test_loc
138
139 def get_temp_file(self, extension=None, dir_name="td", file_name="tf"):
140 """
141 Return a unique new temporary file location to a non-existing temporary
142 file that can safely be created without a risk of name collision.
143 """
144 if extension is None:
145 extension = ".txt"
146
147 if extension and not extension.startswith("."):
148 extension = "." + extension
149
150 file_name = file_name + extension
151 temp_dir = self.get_temp_dir(dir_name)
152 location = path.join(temp_dir, file_name)
153 return location
154
155 def get_temp_dir(self, sub_dir_path=None):
156 """

Calls 2

get_temp_dirMethod · 0.95
joinMethod · 0.45

Tested by

no test coverage detected